From 65d6b001b531cbc03b658e26e4036dee6d9d1f08 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Wed, 18 Apr 2018 18:41:30 -0700 Subject: [PATCH] rename stuff in QnetTypeDefs --- QnetDVAP.cpp | 104 ++++++++++++++++---------------- QnetGateway.cpp | 154 ++++++++++++++++++++++++------------------------ QnetGateway.h | 4 +- QnetRelay.cpp | 14 ++--- QnetTypeDefs.h | 18 +++--- 5 files changed, 147 insertions(+), 147 deletions(-) diff --git a/QnetDVAP.cpp b/QnetDVAP.cpp index 4c9db83..76648f0 100644 --- a/QnetDVAP.cpp +++ b/QnetDVAP.cpp @@ -373,7 +373,7 @@ static void readFrom20000() short seq_no = 0; uint16_t streamid; unsigned char sync_codes[3] = {0x55, 0x2d, 0x16}; - SPKT net_buf; + SDSTR net_buf; unsigned short stream_id_to_dvap = 0; unsigned char frame_pos_to_dvap = 0; unsigned char seq_to_dvap = 0; @@ -400,21 +400,21 @@ static void readFrom20000() } /* check the module and gateway */ - if (net_buf.vpkt.hdr.rpt1[7] != RPTR_MOD) { + if (net_buf.vpkt.hdr.r2[7] != RPTR_MOD) { FD_CLR(insock, &readfd); break; } - memcpy(net_buf.vpkt.hdr.rpt2, OWNER, 7); - net_buf.vpkt.hdr.rpt2[7] = 'G'; + memcpy(net_buf.vpkt.hdr.r1, OWNER, 7); + net_buf.vpkt.hdr.r1[7] = 'G'; if (memcmp(RPTR, OWNER, RPTR_SIZE) != 0) { // restriction mode - memcpy(net_buf.vpkt.hdr.rpt2, RPTR, 7); - memcpy(net_buf.vpkt.hdr.rpt1, RPTR, 7); + memcpy(net_buf.vpkt.hdr.r1, RPTR, 7); + memcpy(net_buf.vpkt.hdr.r2, RPTR, 7); - if (memcmp(net_buf.vpkt.hdr.mycall, OWNER, 7) == 0) { + if (memcmp(net_buf.vpkt.hdr.my, OWNER, 7) == 0) { /* this is an ACK back */ - memcpy(net_buf.vpkt.hdr.mycall, RPTR, 7); + memcpy(net_buf.vpkt.hdr.my, RPTR, 7); } } @@ -444,8 +444,8 @@ static void readFrom20000() printf("Start G2: streamid=%04x, flags=%02x:%02x:%02x, my=%.8s, sfx=%.4s, ur=%.8s, rpt1=%.8s, rpt2=%.8s\n", net_buf.vpkt.streamid, net_buf.vpkt.hdr.flag[0], net_buf.vpkt.hdr.flag[1], net_buf.vpkt.hdr.flag[2], - net_buf.vpkt.hdr.mycall, net_buf.vpkt.hdr.sfx, net_buf.vpkt.hdr.urcall, - net_buf.vpkt.hdr.rpt1, net_buf.vpkt.hdr.rpt2); + net_buf.vpkt.hdr.my, net_buf.vpkt.hdr.nm, net_buf.vpkt.hdr.ur, + net_buf.vpkt.hdr.r2, net_buf.vpkt.hdr.r1); /* save the streamid that is winning */ streamid = net_buf.vpkt.streamid; @@ -477,11 +477,11 @@ static void readFrom20000() //memset(dvp_buf + 6, ' ', 41); for (int f=0; f<3; f++) dr.frame.hdr.flag[f] = net_buf.vpkt.hdr.flag[0]; - memcpy(dr.frame.hdr.rpt1, net_buf.vpkt.hdr.rpt2, 8); - memcpy(dr.frame.hdr.rpt2, net_buf.vpkt.hdr.rpt1, 8); - memcpy(dr.frame.hdr.urcall, net_buf.vpkt.hdr.urcall, 8); - memcpy(dr.frame.hdr.mycall, net_buf.vpkt.hdr.mycall, 8); - memcpy(dr.frame.hdr.sfx, net_buf.vpkt.hdr.sfx, 4); + memcpy(dr.frame.hdr.rpt1, net_buf.vpkt.hdr.r1, 8); + memcpy(dr.frame.hdr.rpt2, net_buf.vpkt.hdr.r2, 8); + memcpy(dr.frame.hdr.urcall, net_buf.vpkt.hdr.ur, 8); + memcpy(dr.frame.hdr.mycall, net_buf.vpkt.hdr.my, 8); + memcpy(dr.frame.hdr.sfx, net_buf.vpkt.hdr.nm, 4); calcPFCS(dr.frame.hdr.flag, dr.frame.hdr.pfcs); frame_pos_to_dvap = 0; seq_to_dvap = 0; @@ -851,8 +851,8 @@ static void RptrAckThread(SDVAP_ACK_ARG *parg) static void ReadDVAPThread() { REPLY_TYPE reply; - SPKT net_buf; - SPKT spack; + SDSTR net_buf; + SDSTR spack; SDVAP_REGISTER dr; time_t tnow = 0; time_t S_ctrl_msg_time = 0; @@ -974,25 +974,25 @@ static void ReadDVAPThread() memcpy(&net_buf.vpkt.hdr, dr.frame.hdr.flag, 41); // copy the header /* RPT1 must always be the repeater + module */ - memcpy(net_buf.vpkt.hdr.rpt2, RPTR_and_MOD, 8); + memcpy(net_buf.vpkt.hdr.r1, RPTR_and_MOD, 8); /* copy RPT2 */ - memcpy(net_buf.vpkt.hdr.rpt1, dr.frame.hdr.rpt1, 8); + memcpy(net_buf.vpkt.hdr.r2, dr.frame.hdr.rpt1, 8); /* RPT2 must also be valid */ - if ((net_buf.vpkt.hdr.rpt1[7] == 'A') || - (net_buf.vpkt.hdr.rpt1[7] == 'B') || - (net_buf.vpkt.hdr.rpt1[7] == 'C') || - (net_buf.vpkt.hdr.rpt1[7] == 'G')) - memcpy(net_buf.vpkt.hdr.rpt1, RPTR, 7); + if ((net_buf.vpkt.hdr.r2[7] == 'A') || + (net_buf.vpkt.hdr.r2[7] == 'B') || + (net_buf.vpkt.hdr.r2[7] == 'C') || + (net_buf.vpkt.hdr.r2[7] == 'G')) + memcpy(net_buf.vpkt.hdr.r2, RPTR, 7); else - memset(net_buf.vpkt.hdr.rpt1, ' ', 8); + memset(net_buf.vpkt.hdr.r2, ' ', 8); - if ((memcmp(net_buf.vpkt.hdr.urcall, "CQCQCQ", 6) != 0) && (net_buf.vpkt.hdr.rpt1[0] != ' ')) - memcpy(net_buf.vpkt.hdr.rpt1, RPTR_and_G, 8); + if ((memcmp(net_buf.vpkt.hdr.ur, "CQCQCQ", 6) != 0) && (net_buf.vpkt.hdr.r2[0] != ' ')) + memcpy(net_buf.vpkt.hdr.r2, RPTR_and_G, 8); /* 8th in rpt1, rpt2 must be diff */ - if (net_buf.vpkt.hdr.rpt1[7] == net_buf.vpkt.hdr.rpt2[7]) - memset(net_buf.vpkt.hdr.rpt1, ' ', 8); + if (net_buf.vpkt.hdr.r2[7] == net_buf.vpkt.hdr.r1[7]) + memset(net_buf.vpkt.hdr.r2, ' ', 8); /* Are we restricting the RF user ? @@ -1002,21 +1002,21 @@ static void ReadDVAPThread() otherwise we drop the rf data */ if (memcmp(RPTR, OWNER, RPTR_SIZE) != 0) { - if (memcmp(net_buf.vpkt.hdr.mycall, RPTR, RPTR_SIZE) != 0) { - printf("mycall=[%.8s], not equal to %s\n", net_buf.vpkt.hdr.mycall, RPTR); + if (memcmp(net_buf.vpkt.hdr.my, RPTR, RPTR_SIZE) != 0) { + printf("mycall=[%.8s], not equal to %s\n", net_buf.vpkt.hdr.my, RPTR); ok = false; } - } else if (memcmp(net_buf.vpkt.hdr.mycall, " ", 8) == 0) { - printf("Invalid value for mycall=[%.8s]\n", net_buf.vpkt.hdr.mycall); + } else if (memcmp(net_buf.vpkt.hdr.my, " ", 8) == 0) { + printf("Invalid value for mycall=[%.8s]\n", net_buf.vpkt.hdr.my); ok = false; } if (ok) { for (i = 0; i < 8; i++) { - if (!isupper(net_buf.vpkt.hdr.mycall[i]) && - !isdigit(net_buf.vpkt.hdr.mycall[i]) && - (net_buf.vpkt.hdr.mycall[i] != ' ')) { - memset(net_buf.vpkt.hdr.mycall, ' ', 8); + if (!isupper(net_buf.vpkt.hdr.my[i]) && + !isdigit(net_buf.vpkt.hdr.my[i]) && + (net_buf.vpkt.hdr.my[i] != ' ')) { + memset(net_buf.vpkt.hdr.my, ' ', 8); ok = false; printf("Invalid value for MYCALL\n"); break; @@ -1024,27 +1024,27 @@ static void ReadDVAPThread() } for (i = 0; i < 4; i++) { - if (!isupper(net_buf.vpkt.hdr.sfx[i]) && - !isdigit(net_buf.vpkt.hdr.sfx[i]) && - (net_buf.vpkt.hdr.sfx[i] != ' ')) { - memset(net_buf.vpkt.hdr.sfx, ' ', 4); + if (!isupper(net_buf.vpkt.hdr.nm[i]) && + !isdigit(net_buf.vpkt.hdr.nm[i]) && + (net_buf.vpkt.hdr.nm[i] != ' ')) { + memset(net_buf.vpkt.hdr.nm, ' ', 4); break; } } for (i = 0; i < 8; i++) { - if (!isupper(net_buf.vpkt.hdr.urcall[i]) && - !isdigit(net_buf.vpkt.hdr.urcall[i]) && - (net_buf.vpkt.hdr.urcall[i] != ' ') && - (net_buf.vpkt.hdr.urcall[i] != '/')) { - memcpy(net_buf.vpkt.hdr.urcall, "CQCQCQ ", 8); + if (!isupper(net_buf.vpkt.hdr.ur[i]) && + !isdigit(net_buf.vpkt.hdr.ur[i]) && + (net_buf.vpkt.hdr.ur[i] != ' ') && + (net_buf.vpkt.hdr.ur[i] != '/')) { + memcpy(net_buf.vpkt.hdr.ur, "CQCQCQ ", 8); break; } } /*** what if YRCALL is all spaces, we can NOT allow that ***/ - if (memcmp(net_buf.vpkt.hdr.urcall, " ", 8) == 0) - memcpy(net_buf.vpkt.hdr.urcall, "CQCQCQ ", 8); + if (memcmp(net_buf.vpkt.hdr.ur, " ", 8) == 0) + memcpy(net_buf.vpkt.hdr.ur, "CQCQCQ ", 8); /* change the rptr flags to net flags */ if (dr.frame.hdr.flag[0] == 0x40) @@ -1061,16 +1061,16 @@ static void ReadDVAPThread() /* for icom g2 */ spack.counter = C_COUNTER++; - memcpy(spack.spkt.mycall, net_buf.vpkt.hdr.mycall, 8); + memcpy(spack.spkt.mycall, net_buf.vpkt.hdr.my, 8); memcpy(spack.spkt.rpt, OWNER, 7); spack.spkt.rpt[7] = RPTR_MOD; sendto(insock, spack.pkt_id, 26, 0, (struct sockaddr *)&outaddr, sizeof(outaddr)); // Before we send the data to the local gateway, // set RPT1, RPT2 to be the local gateway - memcpy(net_buf.vpkt.hdr.rpt2, OWNER, 7); - if (net_buf.vpkt.hdr.rpt1[7] != ' ') - memcpy(net_buf.vpkt.hdr.rpt1, OWNER, 7); + memcpy(net_buf.vpkt.hdr.r1, OWNER, 7); + if (net_buf.vpkt.hdr.r2[7] != ' ') + memcpy(net_buf.vpkt.hdr.r2, OWNER, 7); memcpy(net_buf.pkt_id, "DSTR", 4); net_buf.counter = C_COUNTER++; diff --git a/QnetGateway.cpp b/QnetGateway.cpp index 2f16e04..9487057 100644 --- a/QnetGateway.cpp +++ b/QnetGateway.cpp @@ -993,17 +993,17 @@ void CQnetGateway::process() rptrbuf.counter, rptrbuf.vpkt.streamid, rptrbuf.vpkt.hdr.flag[0], rptrbuf.vpkt.hdr.flag[1], rptrbuf.vpkt.hdr.flag[2], - rptrbuf.vpkt.hdr.mycall, rptrbuf.vpkt.hdr.sfx, rptrbuf.vpkt.hdr.urcall, - rptrbuf.vpkt.hdr.rpt2, rptrbuf.vpkt.hdr.rpt1, recvlen, inet_ntoa(fromRptr.sin_addr)); + rptrbuf.vpkt.hdr.my, rptrbuf.vpkt.hdr.nm, rptrbuf.vpkt.hdr.ur, + rptrbuf.vpkt.hdr.r1, rptrbuf.vpkt.hdr.r2, recvlen, inet_ntoa(fromRptr.sin_addr)); - if ((memcmp(rptrbuf.vpkt.hdr.rpt2, OWNER.c_str(), 7) == 0) && /* rpt1 is this repeater */ + if ((memcmp(rptrbuf.vpkt.hdr.r1, OWNER.c_str(), 7) == 0) && /* rpt1 is this repeater */ /*** (memcmp(rptrbuf + 44, OWNER, 7) != 0) && ***/ /* MYCALL is NOT this repeater */ ((rptrbuf.vpkt.hdr.flag[0] == 0x00) || /* normal */ (rptrbuf.vpkt.hdr.flag[0] == 0x08) || /* EMR */ (rptrbuf.vpkt.hdr.flag[0] == 0x20) || /* BREAK */ (rptrbuf.vpkt.hdr.flag[0] == 0x28))) { /* EMR + BREAK */ - int i = rptrbuf.vpkt.hdr.rpt2[7] - 'A'; + int i = rptrbuf.vpkt.hdr.r1[7] - 'A'; if (i>=0 && i<3) { dtmf_last_frame[i] = 0; @@ -1017,19 +1017,19 @@ void CQnetGateway::process() memcpy(band_txt[i].flags, rptrbuf.vpkt.hdr.flag, 3); - memcpy(band_txt[i].lh_mycall, rptrbuf.vpkt.hdr.mycall, 8); + memcpy(band_txt[i].lh_mycall, rptrbuf.vpkt.hdr.my, 8); band_txt[i].lh_mycall[8] = '\0'; - memcpy(band_txt[i].lh_sfx, rptrbuf.vpkt.hdr.sfx, 4); + memcpy(band_txt[i].lh_sfx, rptrbuf.vpkt.hdr.nm, 4); band_txt[i].lh_sfx[4] = '\0'; - memcpy(band_txt[i].lh_yrcall, rptrbuf.vpkt.hdr.urcall, 8); + memcpy(band_txt[i].lh_yrcall, rptrbuf.vpkt.hdr.ur, 8); band_txt[i].lh_yrcall[8] = '\0'; - memcpy(band_txt[i].lh_rpt1, rptrbuf.vpkt.hdr.rpt2, 8); + memcpy(band_txt[i].lh_rpt1, rptrbuf.vpkt.hdr.r1, 8); band_txt[i].lh_rpt1[8] = '\0'; - memcpy(band_txt[i].lh_rpt2, rptrbuf.vpkt.hdr.rpt1, 8); + memcpy(band_txt[i].lh_rpt2, rptrbuf.vpkt.hdr.r2, 8); band_txt[i].lh_rpt2[8] = '\0'; time(&band_txt[i].last_time); @@ -1064,7 +1064,7 @@ void CQnetGateway::process() /* Is MYCALL valid ? */ memset(temp_radio_user, ' ', 8); - memcpy(temp_radio_user, rptrbuf.vpkt.hdr.mycall, 8); + memcpy(temp_radio_user, rptrbuf.vpkt.hdr.my, 8); temp_radio_user[8] = '\0'; int mycall_valid = regexec(&preg, temp_radio_user, 0, NULL, 0); @@ -1083,18 +1083,18 @@ void CQnetGateway::process() sendto(srv_sock, rptrbuf.pkt_id, recvlen, 0, (struct sockaddr *)&plug, sizeof(struct sockaddr_in)); if ((mycall_valid == REG_NOERROR) && - (memcmp(rptrbuf.vpkt.hdr.urcall, "XRF", 3) != 0) && /* not a reflector */ - (memcmp(rptrbuf.vpkt.hdr.urcall, "REF", 3) != 0) && /* not a reflector */ - (memcmp(rptrbuf.vpkt.hdr.urcall, "DCS", 3) != 0) && /* not a reflector */ - (rptrbuf.vpkt.hdr.urcall[0] != ' ') && /* must have something */ - (memcmp(rptrbuf.vpkt.hdr.urcall, "CQCQCQ", 6) != 0)) { /* urcall is NOT CQCQCQ */ - if ((rptrbuf.vpkt.hdr.urcall[0] == '/') && /* urcall starts with a slash */ - (memcmp(rptrbuf.vpkt.hdr.rpt2, OWNER.c_str(), 7) == 0) && /* rpt1 is this repeater */ - ((rptrbuf.vpkt.hdr.rpt2[7] == 'A') || - (rptrbuf.vpkt.hdr.rpt2[7] == 'B') || - (rptrbuf.vpkt.hdr.rpt2[7] == 'C')) && /* mod is A,B,C */ - (memcmp(rptrbuf.vpkt.hdr.rpt1, OWNER.c_str(), 7) == 0) && /* rpt2 is this repeater */ - (rptrbuf.vpkt.hdr.rpt1[7] == 'G') && /* local Gateway */ + (memcmp(rptrbuf.vpkt.hdr.ur, "XRF", 3) != 0) && /* not a reflector */ + (memcmp(rptrbuf.vpkt.hdr.ur, "REF", 3) != 0) && /* not a reflector */ + (memcmp(rptrbuf.vpkt.hdr.ur, "DCS", 3) != 0) && /* not a reflector */ + (rptrbuf.vpkt.hdr.ur[0] != ' ') && /* must have something */ + (memcmp(rptrbuf.vpkt.hdr.ur, "CQCQCQ", 6) != 0)) { /* urcall is NOT CQCQCQ */ + if ((rptrbuf.vpkt.hdr.ur[0] == '/') && /* urcall starts with a slash */ + (memcmp(rptrbuf.vpkt.hdr.r1, OWNER.c_str(), 7) == 0) && /* rpt1 is this repeater */ + ((rptrbuf.vpkt.hdr.r1[7] == 'A') || + (rptrbuf.vpkt.hdr.r1[7] == 'B') || + (rptrbuf.vpkt.hdr.r1[7] == 'C')) && /* mod is A,B,C */ + (memcmp(rptrbuf.vpkt.hdr.r2, OWNER.c_str(), 7) == 0) && /* rpt2 is this repeater */ + (rptrbuf.vpkt.hdr.r2[7] == 'G') && /* local Gateway */ /*** (memcmp(rptrbuf + 44, OWNER, 7) != 0) && ***/ /* mycall is NOT this repeater */ ((rptrbuf.vpkt.hdr.flag[0] == 0x00) || /* normal */ @@ -1102,8 +1102,8 @@ void CQnetGateway::process() (rptrbuf.vpkt.hdr.flag[0] == 0x20) || /* BK */ (rptrbuf.vpkt.hdr.flag[0] == 0x28)) /* EMR + BK */ ) { - if (memcmp(rptrbuf.vpkt.hdr.urcall+1, OWNER.c_str(), 6) != 0) { /* the value after the slash in urcall, is NOT this repeater */ - int i = rptrbuf.vpkt.hdr.rpt2[7] - 'A'; + if (memcmp(rptrbuf.vpkt.hdr.ur+1, OWNER.c_str(), 6) != 0) { /* the value after the slash in urcall, is NOT this repeater */ + int i = rptrbuf.vpkt.hdr.r1[7] - 'A'; if (i>=0 && i<3) { /* one radio user on a repeater module at a time */ @@ -1112,9 +1112,9 @@ void CQnetGateway::process() /* YRCALL=/KJ4NHFB */ memset(temp_radio_user, ' ', 8); - memcpy(temp_radio_user, rptrbuf.vpkt.hdr.urcall+1, 6); + memcpy(temp_radio_user, rptrbuf.vpkt.hdr.ur+1, 6); temp_radio_user[6] = ' '; - temp_radio_user[7] = rptrbuf.vpkt.hdr.urcall[7]; + temp_radio_user[7] = rptrbuf.vpkt.hdr.ur[7]; if (temp_radio_user[7] == ' ') temp_radio_user[7] = 'A'; temp_radio_user[CALL_SIZE] = '\0'; @@ -1174,13 +1174,13 @@ void CQnetGateway::process() } } } - } else if ((memcmp(rptrbuf.vpkt.hdr.urcall, OWNER.c_str(), 7) != 0) && /* urcall is not this repeater */ - (memcmp(rptrbuf.vpkt.hdr.rpt2, OWNER.c_str(), 7) == 0) && /* rpt1 is this repeater */ - ((rptrbuf.vpkt.hdr.rpt2[7] == 'A') || - (rptrbuf.vpkt.hdr.rpt2[7] == 'B') || - (rptrbuf.vpkt.hdr.rpt2[7] == 'C')) && /* mod is A,B,C */ - (memcmp(rptrbuf.vpkt.hdr.rpt1, OWNER.c_str(), 7) == 0) && /* rpt2 is this repeater */ - (rptrbuf.vpkt.hdr.rpt1[7] == 'G') && /* local Gateway */ + } else if ((memcmp(rptrbuf.vpkt.hdr.ur, OWNER.c_str(), 7) != 0) && /* urcall is not this repeater */ + (memcmp(rptrbuf.vpkt.hdr.r1, OWNER.c_str(), 7) == 0) && /* rpt1 is this repeater */ + ((rptrbuf.vpkt.hdr.r1[7] == 'A') || + (rptrbuf.vpkt.hdr.r1[7] == 'B') || + (rptrbuf.vpkt.hdr.r1[7] == 'C')) && /* mod is A,B,C */ + (memcmp(rptrbuf.vpkt.hdr.r2, OWNER.c_str(), 7) == 0) && /* rpt2 is this repeater */ + (rptrbuf.vpkt.hdr.r2[7] == 'G') && /* local Gateway */ /*** (memcmp(rptrbuf + 44, OWNER, 7) != 0) && ***/ /* mycall is NOT this repeater */ ((rptrbuf.vpkt.hdr.flag[0] == 0x00) || /* normal */ @@ -1190,13 +1190,13 @@ void CQnetGateway::process() ) { memset(temp_radio_user, ' ', 8); - memcpy(temp_radio_user, rptrbuf.vpkt.hdr.urcall, 8); + memcpy(temp_radio_user, rptrbuf.vpkt.hdr.ur, 8); temp_radio_user[8] = '\0'; bool result = get_yrcall_rptr(temp_radio_user, arearp_cs, zonerp_cs, &temp_mod, ip, 'U'); if (result) { /* destination is a remote system */ if (memcmp(zonerp_cs, OWNER.c_str(), 7) != 0) { - int i = rptrbuf.vpkt.hdr.rpt2[7] - 'A'; + int i = rptrbuf.vpkt.hdr.r1[7] - 'A'; if (i>=0 && i<3) { /* one radio user on a repeater module at a time */ @@ -1250,17 +1250,17 @@ void CQnetGateway::process() } } } else { - int i = rptrbuf.vpkt.hdr.rpt2[7] - 'A'; + int i = rptrbuf.vpkt.hdr.r1[7] - 'A'; if (i>=0 && i<3) { /* the user we are trying to contact is on our gateway */ /* make sure they are on a different module */ - if (temp_mod != rptrbuf.vpkt.hdr.rpt2[7]) { + if (temp_mod != rptrbuf.vpkt.hdr.r1[7]) { /* 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); + memcpy(band_txt[i].dest_rptr, rptrbuf.vpkt.hdr.r2, 8); band_txt[i].dest_rptr[7] = temp_mod; band_txt[i].dest_rptr[8] = '\0'; @@ -1273,10 +1273,10 @@ void CQnetGateway::process() band_txt[i] : local RF is talking. */ if ((toRptr[i].last_time == 0) && (band_txt[i].last_time == 0)) { - printf("CALLmode cross-banding from mod %c to %c\n", rptrbuf.vpkt.hdr.rpt2[7], temp_mod); + printf("CALLmode cross-banding from mod %c to %c\n", rptrbuf.vpkt.hdr.r1[7], temp_mod); - rptrbuf.vpkt.hdr.rpt1[7] = temp_mod; - rptrbuf.vpkt.hdr.rpt2[7] = 'G'; + rptrbuf.vpkt.hdr.r2[7] = temp_mod; + rptrbuf.vpkt.hdr.r1[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)); @@ -1295,15 +1295,15 @@ void CQnetGateway::process() } } } else - printf("icom rule: no routing from %.8s to %s%c\n", rptrbuf.vpkt.hdr.rpt2, arearp_cs, temp_mod); + printf("icom rule: no routing from %.8s to %s%c\n", rptrbuf.vpkt.hdr.r1, arearp_cs, temp_mod); } } } } - } else if ((rptrbuf.vpkt.hdr.urcall[7] == '0') && - (rptrbuf.vpkt.hdr.urcall[6] == 'C') && - (rptrbuf.vpkt.hdr.urcall[0] == ' ')) { - int i = rptrbuf.vpkt.hdr.rpt2[7] - 'A'; + } else if ((rptrbuf.vpkt.hdr.ur[7] == '0') && + (rptrbuf.vpkt.hdr.ur[6] == 'C') && + (rptrbuf.vpkt.hdr.ur[0] == ' ')) { + int i = rptrbuf.vpkt.hdr.r1[7] - 'A'; if (i>=0 && i<3) { /* voicemail file is closed */ @@ -1314,11 +1314,11 @@ void CQnetGateway::process() } else printf("No voicemail to clear or still recording\n"); } - } else if ((rptrbuf.vpkt.hdr.urcall[7] == '0') && - (rptrbuf.vpkt.hdr.urcall[6] == 'R') && - (rptrbuf.vpkt.hdr.urcall[0] == ' ')) { + } else if ((rptrbuf.vpkt.hdr.ur[7] == '0') && + (rptrbuf.vpkt.hdr.ur[6] == 'R') && + (rptrbuf.vpkt.hdr.ur[0] == ' ')) { int i = -1; - switch (rptrbuf.vpkt.hdr.rpt2[7]) { + switch (rptrbuf.vpkt.hdr.r1[7]) { case 'A': i = 0; break; @@ -1341,10 +1341,10 @@ void CQnetGateway::process() } else printf("No voicemail to recall or still recording\n"); } - } else if ((rptrbuf.vpkt.hdr.urcall[7] == '0') && - (rptrbuf.vpkt.hdr.urcall[6] == 'S') && - (rptrbuf.vpkt.hdr.urcall[0] == ' ')) { - int i = rptrbuf.vpkt.hdr.rpt2[7] - 'A'; + } else if ((rptrbuf.vpkt.hdr.ur[7] == '0') && + (rptrbuf.vpkt.hdr.ur[6] == 'S') && + (rptrbuf.vpkt.hdr.ur[0] == ' ')) { + int i = rptrbuf.vpkt.hdr.r1[7] - 'A'; if (i>=0 && i<3) { if (vm[i].fd >= 0) @@ -1353,7 +1353,7 @@ void CQnetGateway::process() memset(tempfile, '\0', sizeof(tempfile)); snprintf(tempfile, FILENAME_MAX, "%s/%c_%s", echotest_dir.c_str(), - rptrbuf.vpkt.hdr.rpt2[7], + rptrbuf.vpkt.hdr.r1[7], "voicemail.dat"); vm[i].fd = open(tempfile, @@ -1364,7 +1364,7 @@ void CQnetGateway::process() else { strcpy(vm[i].file, tempfile); printf("Recording mod %c for voicemail into file:[%s]\n", - rptrbuf.vpkt.hdr.rpt2[7], + rptrbuf.vpkt.hdr.r1[7], vm[i].file); time(&vm[i].last_time); @@ -1380,7 +1380,7 @@ void CQnetGateway::process() memcpy(&recbuf.streamid, &rptrbuf.vpkt.streamid, 44); memset(recbuf.hdr.rpt1, ' ', 8); memcpy(recbuf.hdr.rpt1, OWNER.c_str(), OWNER.length()); - recbuf.hdr.rpt1[7] = rptrbuf.vpkt.hdr.rpt2[7]; + recbuf.hdr.rpt1[7] = rptrbuf.vpkt.hdr.r1[7]; memset(recbuf.hdr.rpt2, ' ', 8); memcpy(recbuf.hdr.rpt2, OWNER.c_str(), OWNER.length()); recbuf.hdr.rpt2[7] = 'G'; @@ -1396,8 +1396,8 @@ void CQnetGateway::process() } } } - } else if (('E' == rptrbuf.vpkt.hdr.urcall[7]) && (' ' == rptrbuf.vpkt.hdr.urcall[0])) { - int i = rptrbuf.vpkt.hdr.rpt2[7] - 'A'; + } else if (('E' == rptrbuf.vpkt.hdr.ur[7]) && (' ' == rptrbuf.vpkt.hdr.ur[0])) { + int i = rptrbuf.vpkt.hdr.r1[7] - 'A'; if (i>=0 && i<3) { if (recd[i].fd >= 0) @@ -1405,7 +1405,7 @@ void CQnetGateway::process() else { memset(tempfile, '\0', sizeof(tempfile)); snprintf(tempfile, FILENAME_MAX, "%s/%c_%s", echotest_dir.c_str(), - rptrbuf.vpkt.hdr.rpt2[7], "echotest.dat"); + rptrbuf.vpkt.hdr.r1[7], "echotest.dat"); recd[i].fd = open(tempfile, O_CREAT | O_WRONLY | O_EXCL | O_TRUNC | O_APPEND, @@ -1415,7 +1415,7 @@ void CQnetGateway::process() else { strcpy(recd[i].file, tempfile); printf("Recording mod %c for echotest into file:[%s]\n", - rptrbuf.vpkt.hdr.rpt2[7], recd[i].file); + rptrbuf.vpkt.hdr.r1[7], recd[i].file); time(&recd[i].last_time); recd[i].streamid = rptrbuf.vpkt.streamid; @@ -1430,7 +1430,7 @@ void CQnetGateway::process() memcpy(&recbuf.streamid, &rptrbuf.vpkt.streamid, 44); memset(recbuf.hdr.rpt1, ' ', 8); memcpy(recbuf.hdr.rpt1, OWNER.c_str(), OWNER.length()); - recbuf.hdr.rpt1[7] = rptrbuf.vpkt.hdr.rpt2[7]; + recbuf.hdr.rpt1[7] = rptrbuf.vpkt.hdr.r1[7]; memset(recbuf.hdr.rpt2, ' ', 8); memcpy(recbuf.hdr.rpt2, OWNER.c_str(), OWNER.length()); recbuf.hdr.rpt2[7] = 'G'; @@ -1447,35 +1447,35 @@ void CQnetGateway::process() } } /* 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 */ - int i = rptrbuf.vpkt.hdr.rpt2[7] - 'A'; + } else if (0 == (memcmp(rptrbuf.vpkt.hdr.ur, "CQCQCQ", 6)) && /* yrcall is CQCQCQ */ + (0 == memcmp(rptrbuf.vpkt.hdr.r2, OWNER.c_str(), 7)) && /* rpt1 is this repeater */ + (0 == memcmp(rptrbuf.vpkt.hdr.r1, OWNER.c_str(), 7)) && /* rpt2 is this repeater */ + ((rptrbuf.vpkt.hdr.r1[7] == 'A') || + (rptrbuf.vpkt.hdr.r1[7] == 'B') || + (rptrbuf.vpkt.hdr.r1[7] == 'C')) && /* mod of rpt1 is A,B,C */ + ((rptrbuf.vpkt.hdr.r2[7] == 'A') || + (rptrbuf.vpkt.hdr.r2[7] == 'B') || + (rptrbuf.vpkt.hdr.r2[7] == 'C')) && /* !!! usually a G of rpt2, but we see A,B,C */ + (rptrbuf.vpkt.hdr.r2[7] != rptrbuf.vpkt.hdr.r1[7])) { /* cross-banding? make sure NOT the same */ + int i = rptrbuf.vpkt.hdr.r1[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); + memcpy(band_txt[i].dest_rptr, rptrbuf.vpkt.hdr.r2, 8); band_txt[i].dest_rptr[8] = '\0'; } - i = rptrbuf.vpkt.hdr.rpt1[7] - 'A'; + i = rptrbuf.vpkt.hdr.r2[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)) { - printf("ZONEmode cross-banding from mod %c to %c\n", rptrbuf.vpkt.hdr.rpt2[7], rptrbuf.vpkt.hdr.rpt1[7]); + printf("ZONEmode cross-banding from mod %c to %c\n", rptrbuf.vpkt.hdr.r1[7], rptrbuf.vpkt.hdr.r2[7]); - rptrbuf.vpkt.hdr.rpt2[7] = 'G'; + rptrbuf.vpkt.hdr.r1[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)); diff --git a/QnetGateway.h b/QnetGateway.h index 96a596f..17adabe 100644 --- a/QnetGateway.h +++ b/QnetGateway.h @@ -118,10 +118,10 @@ private: // input from our own local repeater modules int srv_sock = -1; - SPKT rptrbuf; // 58 or 29 or 32, max is 58 + SDSTR rptrbuf; // 58 or 29 or 32, max is 58 struct sockaddr_in fromRptr; - SPKT end_of_audio; + SDSTR end_of_audio; // send packets to g2_link struct sockaddr_in plug; diff --git a/QnetRelay.cpp b/QnetRelay.cpp index abc0c38..bf5656b 100644 --- a/QnetRelay.cpp +++ b/QnetRelay.cpp @@ -230,10 +230,10 @@ int CQnetRelay::SendTo(const int fd, const unsigned char *buf, const int size, c bool CQnetRelay::ProcessGateway(const int len, const unsigned char *raw) { if (29==len || 58==len) { //here is dstar data - SPKT buf; - ::memcpy(buf.pkt_id, raw, len); // transfer raw data to SPKT struct + SDSTR buf; + ::memcpy(buf.pkt_id, raw, len); // transfer raw data to SDSTR struct - SMMDVMPKT pkt; // destination + SDSRP pkt; // destination // fill in some inital stuff ::memcpy(pkt.title, "DSRP", 4); pkt.voice.id = buf.vpkt.streamid; @@ -277,9 +277,9 @@ bool CQnetRelay::ProcessMMDVM(const int len, const unsigned char *raw) { static short old_id = 0U; static short stream_id = 0U; - SMMDVMPKT mpkt; + SDSRP mpkt; if (len < 65) - ::memcpy(mpkt.title, raw, len); // transfer raw data to SMMDVMPKT struct + ::memcpy(mpkt.title, raw, len); // transfer raw data to SDSRP struct if (49==len || 21==len) { // grab the stream id if this is a header @@ -290,7 +290,7 @@ bool CQnetRelay::ProcessMMDVM(const int len, const unsigned char *raw) old_id = stream_id; } - SPKT gpkt; // destination + SDSTR gpkt; // destination // sets most of the params ::memcpy(gpkt.pkt_id, "DSTR", 4); gpkt.counter = COUNTER++; @@ -312,7 +312,7 @@ bool CQnetRelay::ProcessMMDVM(const int len, const unsigned char *raw) printf("ERROR: ProcessMMDVM: Could not write gateway header packet\n"); return true; } - printf("INFO: ProcessMMDVM: sent header to port %u pkt = '%s'\n", G2_IN_PORT, std::string((char *)gpkt.vpkt.hdr.rpt1, 36).c_str()); + printf("INFO: ProcessMMDVM: sent header to port %u pkt = '%s'\n", G2_IN_PORT, std::string((char *)gpkt.vpkt.hdr.r2, 36).c_str()); } else if (21 == len) { // ambe gpkt.remaining = 0x16; gpkt.vpkt.ctrl = mpkt.header.seq; diff --git a/QnetTypeDefs.h b/QnetTypeDefs.h index 4e7fd77..4f17183 100644 --- a/QnetTypeDefs.h +++ b/QnetTypeDefs.h @@ -39,11 +39,11 @@ typedef struct pkt_tag { union { struct { unsigned char flag[3]; // 17 - unsigned char rpt1[8]; // 20 - unsigned char rpt2[8]; // 28 - unsigned char urcall[8];// 36 - unsigned char mycall[8];// 44 - unsigned char sfx[4]; // 52 + unsigned char r2[8]; // 20 + unsigned char r1[8]; // 28 + unsigned char ur[8]; // 36 + unsigned char my[8]; // 44 + unsigned char nm[4]; // 52 unsigned char pfcs[2]; // 56 } hdr; // total 58 union { @@ -60,7 +60,7 @@ typedef struct pkt_tag { }; } vpkt; }; -} SPKT; +} SDSTR; #pragma pack(pop) // for the g2 external port @@ -76,7 +76,7 @@ typedef struct dsvt_tag { union { struct { // index unsigned char flag[3]; // 15 - unsigned char rpt1[8]; // 18 + unsigned char rpt1[8]; // 18 unsigned char rpt2[8]; // 26 unsigned char urcall[8];// 34 unsigned char mycall[8];// 42 @@ -111,7 +111,7 @@ typedef struct mmdvm_tag { // offset size unsigned char yr[8]; // Your Call 27 unsigned char my[8]; // My Call 35 unsigned char nm[4]; // Name 43 - unsigned short pcfs; // checksum 47 49 + unsigned short pfcs; // checksum 47 49 } header; struct { unsigned short id; // random id number 5 @@ -121,5 +121,5 @@ typedef struct mmdvm_tag { // offset size unsigned char ambe[12]; // voice + slow data 9 21 } voice; }; -} SMMDVMPKT; +} SDSRP; #pragma pack(pop)