diff --git a/g2_ircddb.cpp b/g2_ircddb.cpp index 5d685b1..e156279 100644 --- a/g2_ircddb.cpp +++ b/g2_ircddb.cpp @@ -1594,55 +1594,54 @@ static void runit() } } } - } else - /* check for cross-banding */ - if (0 == (memcmp(rptrbuf.vpkt.hdr.urcall, "CQCQCQ", 6)) && /* yrcall is CQCQCQ */ - (0 == memcmp(rptrbuf.vpkt.hdr.rpt1, OWNER.c_str(), 7)) && /* rpt1 is this repeater */ - (0 == memcmp(rptrbuf.vpkt.hdr.rpt2, OWNER.c_str(), 7)) && /* rpt2 is this repeater */ - ((rptrbuf.vpkt.hdr.rpt2[7] == 'A') || - (rptrbuf.vpkt.hdr.rpt2[7] == 'B') || - (rptrbuf.vpkt.hdr.rpt2[7] == 'C')) && /* mod of rpt1 is A,B,C */ - ((rptrbuf.vpkt.hdr.rpt1[7] == 'A') || - (rptrbuf.vpkt.hdr.rpt1[7] == 'B') || - (rptrbuf.vpkt.hdr.rpt1[7] == 'C')) && /* !!! usually a G of rpt2, but we see A,B,C */ - (rptrbuf.vpkt.hdr.rpt1[7] != rptrbuf.vpkt.hdr.rpt2[7])) { /* cross-banding? make sure NOT the same */ - i = rptrbuf.vpkt.hdr.rpt2[7] - 'A'; - - if (i>=0 && i<3) { - // The remote repeater has been set, lets fill in the dest_rptr - // so that later we can send that to the LIVE web site - memcpy(band_txt[i].dest_rptr, rptrbuf.vpkt.hdr.rpt1, 8); - band_txt[i].dest_rptr[8] = '\0'; - } + /* check for cross-banding */ + } else if (0 == (memcmp(rptrbuf.vpkt.hdr.urcall, "CQCQCQ", 6)) && /* yrcall is CQCQCQ */ + (0 == memcmp(rptrbuf.vpkt.hdr.rpt1, OWNER.c_str(), 7)) && /* rpt1 is this repeater */ + (0 == memcmp(rptrbuf.vpkt.hdr.rpt2, OWNER.c_str(), 7)) && /* rpt2 is this repeater */ + ((rptrbuf.vpkt.hdr.rpt2[7] == 'A') || + (rptrbuf.vpkt.hdr.rpt2[7] == 'B') || + (rptrbuf.vpkt.hdr.rpt2[7] == 'C')) && /* mod of rpt1 is A,B,C */ + ((rptrbuf.vpkt.hdr.rpt1[7] == 'A') || + (rptrbuf.vpkt.hdr.rpt1[7] == 'B') || + (rptrbuf.vpkt.hdr.rpt1[7] == 'C')) && /* !!! usually a G of rpt2, but we see A,B,C */ + (rptrbuf.vpkt.hdr.rpt1[7] != rptrbuf.vpkt.hdr.rpt2[7])) { /* cross-banding? make sure NOT the same */ + i = rptrbuf.vpkt.hdr.rpt2[7] - 'A'; + + if (i>=0 && i<3) { + // The remote repeater has been set, lets fill in the dest_rptr + // so that later we can send that to the LIVE web site + memcpy(band_txt[i].dest_rptr, rptrbuf.vpkt.hdr.rpt1, 8); + band_txt[i].dest_rptr[8] = '\0'; + } - i = rptrbuf.vpkt.hdr.rpt1[7] - 'A'; + i = rptrbuf.vpkt.hdr.rpt1[7] - 'A'; - /* valid destination repeater module? */ - if (i>=0 && i<3) { - // toRptr[i] : receiving from a remote system or cross-band - // band_txt[i] : local RF is talking. - if ((toRptr[i].last_time == 0) && (band_txt[i].last_time == 0)) { - traceit("ZONEmode cross-banding from mod %c to %c\n", rptrbuf.vpkt.hdr.rpt2[7], rptrbuf.vpkt.hdr.rpt1[7]); + /* valid destination repeater module? */ + if (i>=0 && i<3) { + // toRptr[i] : receiving from a remote system or cross-band + // band_txt[i] : local RF is talking. + if ((toRptr[i].last_time == 0) && (band_txt[i].last_time == 0)) { + traceit("ZONEmode cross-banding from mod %c to %c\n", rptrbuf.vpkt.hdr.rpt2[7], rptrbuf.vpkt.hdr.rpt1[7]); - rptrbuf.vpkt.hdr.rpt2[7] = 'G'; - calcPFCS(rptrbuf.pkt_id, 58); + rptrbuf.vpkt.hdr.rpt2[7] = 'G'; + calcPFCS(rptrbuf.pkt_id, 58); - sendto(srv_sock, rptrbuf.pkt_id, 58, 0, (struct sockaddr *)&toRptr[i].band_addr, sizeof(struct sockaddr_in)); + sendto(srv_sock, rptrbuf.pkt_id, 58, 0, (struct sockaddr *)&toRptr[i].band_addr, sizeof(struct sockaddr_in)); - /* This is the active streamid */ - toRptr[i].streamid = rptrbuf.vpkt.streamid; - toRptr[i].adr = fromRptr.sin_addr.s_addr; + /* This is the active streamid */ + toRptr[i].streamid = rptrbuf.vpkt.streamid; + toRptr[i].adr = fromRptr.sin_addr.s_addr; - /* time it, in case stream times out */ - time(&toRptr[i].last_time); + /* time it, in case stream times out */ + time(&toRptr[i].last_time); - /* bump the G2 counter */ - toRptr[i].G2_COUNTER ++; + /* bump the G2 counter */ + toRptr[i].G2_COUNTER ++; - toRptr[i].sequence = rptrbuf.vpkt.ctrl; - } + toRptr[i].sequence = rptrbuf.vpkt.ctrl; } } + } } else { for (i = 0; i < 3; i++) { if (band_txt[i].streamID == rptrbuf.vpkt.streamid) { diff --git a/g2_link.cpp b/g2_link.cpp index 9f3526a..5cdb4f6 100644 --- a/g2_link.cpp +++ b/g2_link.cpp @@ -162,8 +162,6 @@ static struct { static int xrf_g2_sock = -1; static int ref_g2_sock = -1; static int dcs_g2_sock = -1; -static unsigned char dcs_buf[1000]; -static unsigned char readBuffer2[1024]; static struct sockaddr_in fromDst4; // After we receive it from remote g2, @@ -172,7 +170,6 @@ static struct sockaddr_in toLocalg2; // input from our own local repeater static int rptr_sock = -1; -static unsigned char readBuffer[100]; // 58 or 29 or 32, max is 58 static struct sockaddr_in fromRptr; static fd_set fdset; @@ -1272,6 +1269,9 @@ static void runit() char tmp1[CALL_SIZE + 1]; char tmp2[36]; // 8 for rpt1 + 24 for time_t in std::string format + unsigned char readBuffer[100]; // 58 or 29 or 32, max is 58 + unsigned char readBuffer2[1024]; + unsigned char dcs_buf[1000]; dt_lh_type::iterator dt_lh_pos; dt_lh_type::reverse_iterator r_dt_lh_pos; @@ -2140,8 +2140,7 @@ static void runit() if (FD_ISSET(ref_g2_sock, &fdset)) { fromlen = sizeof(struct sockaddr_in); - recvlen2 = recvfrom(ref_g2_sock,(char *)readBuffer2,100, - 0,(struct sockaddr *)&fromDst4,&fromlen); + recvlen2 = recvfrom(ref_g2_sock, (char *)readBuffer2, 100, 0, (struct sockaddr *)&fromDst4,&fromlen); strncpy(ip, inet_ntoa(fromDst4.sin_addr),IP_SIZE); ip[IP_SIZE] = '\0'; @@ -3277,20 +3276,15 @@ static void runit() if (FD_ISSET(rptr_sock, &fdset)) { fromlen = sizeof(struct sockaddr_in); - recvlen = recvfrom(rptr_sock,(char *)readBuffer,100, - 0,(struct sockaddr *)&fromRptr,&fromlen); + recvlen = recvfrom(rptr_sock, (char *)readBuffer, 100, 0, (struct sockaddr *)&fromRptr,&fromlen); - if ( ((recvlen == 58) || - (recvlen == 29) || - (recvlen == 32)) && + if ( ((recvlen == 58) || (recvlen == 29) || (recvlen == 32)) && (readBuffer[6] == 0x73) && (readBuffer[7] == 0x12) && ((memcmp(readBuffer,"DSTR", 4) == 0) || (memcmp(readBuffer,"CCS_", 4) == 0)) && (readBuffer[10] == 0x20) && (readBuffer[8] == 0x00) && - ((readBuffer[9] == 0x30) || - (readBuffer[9] == 0x13) || - (readBuffer[9] == 0x16)) ) { + ((readBuffer[9] == 0x30) || (readBuffer[9] == 0x13) || (readBuffer[9] == 0x16)) ) { if (recvlen == 58) { if (qso_details)