Qnet Struct processing

pull/5/head
Tom Early 8 years ago
parent 6b205412e6
commit edaa0c5905

@ -807,7 +807,7 @@ void CQnetGateway::process()
// Send end_of_audio to local repeater.
// Let the repeater re-initialize
end_of_audio.counter = toRptr[i].G2_COUNTER;
end_of_audio.counter = is_icom ? G2_COUNTER_OUT++ :toRptr[i].G2_COUNTER++;
if (i == 0)
end_of_audio.vpkt.snd_term_id = 0x03;
else if (i == 1)
@ -820,7 +820,6 @@ void CQnetGateway::process()
for (int j=0; j<2; j++)
sendto(srv_sock, end_of_audio.pkt_id, 29, 0, (struct sockaddr *)&toRptr[i].band_addr, sizeof(struct sockaddr_in));
toRptr[i].G2_COUNTER++;
toRptr[i].streamid = 0;
toRptr[i].adr = 0;
@ -929,7 +928,20 @@ void CQnetGateway::process()
rptrbuf.flag[2] = 0x00;
rptrbuf.remaining = 0x30;
rptrbuf.vpkt.icm_id = 0x20;
memcpy(&rptrbuf.vpkt.dst_rptr_id, g2buf.flagb, 47);
//memcpy(&rptrbuf.vpkt.dst_rptr_id, g2buf.flagb, 47);
rptrbuf.vpkt.dst_rptr_id = g2buf.flagb[0];
rptrbuf.vpkt.snd_rptr_id = g2buf.flagb[1];
rptrbuf.vpkt.snd_term_id = g2buf.flagb[2];
rptrbuf.vpkt.streamid = g2buf.streamid;
rptrbuf.vpkt.ctrl = g2buf.ctrl;
memcpy(rptrbuf.vpkt.hdr.flag, g2buf.hdr.flag, 3);
memcpy(rptrbuf.vpkt.hdr.r1, g2buf.hdr.rpt1, 8);
memcpy(rptrbuf.vpkt.hdr.r2, g2buf.hdr.rpt2, 8);
memcpy(rptrbuf.vpkt.hdr.ur, g2buf.hdr.urcall, 8);
memcpy(rptrbuf.vpkt.hdr.my, g2buf.hdr.mycall, 8);
memcpy(rptrbuf.vpkt.hdr.nm, g2buf.hdr.sfx, 4);
memcpy(rptrbuf.vpkt.hdr.pfcs, g2buf.hdr.pfcs, 2);
sendto(srv_sock, rptrbuf.pkt_id, 58, 0, (struct sockaddr *)&toRptr[i].band_addr, sizeof(struct sockaddr_in));
/* save the header */
@ -947,7 +959,7 @@ void CQnetGateway::process()
}
}
} else { // g2buflen == 27
if (bool_qso_details && g2buf.counter & 0x40)
if (bool_qso_details && g2buf.ctrl & 0x40)
printf("id=%04x END G2\n", ntohs(g2buf.streamid));
/* find out which repeater module to send the data to */
@ -973,7 +985,7 @@ void CQnetGateway::process()
toRptr[i].sequence = rptrbuf.vpkt.ctrl;
/* End of stream ? */
if (g2buf.counter & 0x40) {
if (g2buf.ctrl & 0x40) {
/* clear the saved header */
memset(toRptr[i].saved_hdr, 0, sizeof(toRptr[i].saved_hdr));
toRptr[i].saved_adr = 0;
@ -990,7 +1002,7 @@ void CQnetGateway::process()
if ((i == 3) && bool_regen_header) {
/* check if this a continuation of audio that timed out */
if (g2buf.counter & 0x40)
if (g2buf.ctrl & 0x40)
; /* we do not care about end-of-QSO */
else {
/* for which repeater this stream has timed out ? */
@ -2442,7 +2454,19 @@ void CQnetGateway::PlayFileThread(char *file)
dstr.flag[2] = 0x00;
dstr.remaining = 0x30;
dstr.vpkt.icm_id = 0x20;
memcpy(&dstr.vpkt.dst_rptr_id, dsvt.flagb, 47);
//memcpy(&dstr.vpkt.dst_rptr_id, dsvt.flagb, 47);
dstr.vpkt.dst_rptr_id = dsvt.flagb[0];
dstr.vpkt.snd_rptr_id = dsvt.flagb[1];
dstr.vpkt.snd_term_id = dsvt.flagb[2];
dstr.vpkt.streamid = dsvt.streamid;
dstr.vpkt.ctrl = dsvt.ctrl;
memcpy(dstr.vpkt.hdr.flag, dsvt.hdr.flag, 3);
memcpy(dstr.vpkt.hdr.r1, dsvt.hdr.rpt1, 8);
memcpy(dstr.vpkt.hdr.r2, dsvt.hdr.rpt2, 8);
memcpy(dstr.vpkt.hdr.ur, dsvt.hdr.urcall, 8);
memcpy(dstr.vpkt.hdr.my, dsvt.hdr.mycall, 8);
memcpy(dstr.vpkt.hdr.nm, dsvt.hdr.sfx, 4);
memcpy(dstr.vpkt.hdr.pfcs, dsvt.hdr.pfcs, 2);
/* We did not change anything */
// calcPFCS(rptr_buf, 58);

@ -197,7 +197,7 @@ void CQnetLink::RptrAckThread(char *arg)
dsvt.flagb[1] = 0x1;
dsvt.streamid = htons(streamid_raw);
dsvt.counter = 0x80;
dsvt.ctrl = 0x80;
dsvt.hdr.flag[0] = 0x1;
dsvt.hdr.flag[1] = dsvt.hdr.flag[2] = 0x0;
@ -223,7 +223,7 @@ void CQnetLink::RptrAckThread(char *arg)
/* start sending silence + announcement text */
for (int i=0; i<10; i++) {
dsvt.counter = (unsigned char)i;
dsvt.ctrl = (unsigned char)i;
switch (i) {
case 0:
dsvt.vasd.text[0] = 0x55;
@ -271,7 +271,7 @@ void CQnetLink::RptrAckThread(char *arg)
dsvt.vasd.text[2] = RADIO_ID[19] ^ 0x93;
break;
case 9:
dsvt.counter |= 0x40;
dsvt.ctrl |= 0x40;
dsvt.vasd.text[0] = 0x16;
dsvt.vasd.text[1] = 0x29;
dsvt.vasd.text[2] = 0xf5;
@ -1716,7 +1716,7 @@ void CQnetLink::Process()
}
}
} else if (found) { // length is 27
if ((dsvt.counter & 0x40) != 0) {
if ((dsvt.ctrl & 0x40) != 0) {
for (int i=0; i<3; i++) {
if (old_sid[i].sid == dsvt.streamid) {
if (qso_details)
@ -1761,7 +1761,7 @@ void CQnetLink::Process()
sendto(rptr_sock, from_xrf_torptr_brd.title, 27, 0, (struct sockaddr *)&toLocalg2, sizeof(struct sockaddr_in));
}
if (dsvt.counter & 0x40) {
if (dsvt.ctrl & 0x40) {
brd_from_xrf.xrf_streamid = brd_from_xrf.rptr_streamid[0] = brd_from_xrf.rptr_streamid[1] = 0x0;
brd_from_xrf_idx = 0;
}
@ -1796,7 +1796,7 @@ void CQnetLink::Process()
memcpy(dcs_buf + 31, xrf_2_dcs[i].mycall, 8);
memcpy(dcs_buf + 39, xrf_2_dcs[i].sfx, 4);
memcpy(dcs_buf + 43, &dsvt.streamid, 2);
dcs_buf[45] = dsvt.counter; /* cycle sequence */
dcs_buf[45] = dsvt.ctrl; /* cycle sequence */
memcpy(dcs_buf + 46, dsvt.vasd.voice, 12);
dcs_buf[58] = (xrf_2_dcs[i].dcs_rptr_seq >> 0) & 0xff;
@ -1811,7 +1811,7 @@ void CQnetLink::Process()
sendto(dcs_g2_sock, dcs_buf, 100, 0, (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(to_remote_g2[i].toDst4));
}
if (dsvt.counter & 0x40) {
if (dsvt.ctrl & 0x40) {
to_remote_g2[i].in_streamid = 0x0;
}
break;
@ -2501,7 +2501,7 @@ void CQnetLink::Process()
}
}
} else if (found) {
if (rdsvt.dsvt.counter & 0x40U) {
if (rdsvt.dsvt.ctrl & 0x40U) {
for (int i=0; i<3; i++) {
if (old_sid[i].sid == rdsvt.dsvt.streamid) {
if (qso_details)
@ -2562,7 +2562,7 @@ void CQnetLink::Process()
sendto(dcs_g2_sock, dcs_buf, 100, 0, (struct sockaddr *)&(to_remote_g2[i].toDst4), sizeof(to_remote_g2[i].toDst4));
}
if (rdsvt.dsvt.counter & 0x40) {
if (rdsvt.dsvt.ctrl & 0x40) {
to_remote_g2[i].in_streamid = 0x0;
}
break;
@ -2655,7 +2655,7 @@ void CQnetLink::Process()
else
rdsvt.dsvt.flagb[2] = 0x02;
memcpy(&rdsvt.dsvt.streamid, dcs_buf+43, 2);
rdsvt.dsvt.counter = 0x80;
rdsvt.dsvt.ctrl = 0x80;
rdsvt.dsvt.hdr.flag[0] = rdsvt.dsvt.hdr.flag[1] = rdsvt.dsvt.hdr.flag[2] = 0x00;
memcpy(rdsvt.dsvt.hdr.rpt1, owner.c_str(), CALL_SIZE);
rdsvt.dsvt.hdr.rpt1[7] = to_remote_g2[i].from_mod;
@ -2697,7 +2697,7 @@ void CQnetLink::Process()
else
rdsvt.dsvt.flagb[2] = 0x02;
memcpy(&rdsvt.dsvt.streamid, dcs_buf+43, 2);
rdsvt.dsvt.counter = dcs_buf[45];
rdsvt.dsvt.ctrl = dcs_buf[45];
memcpy(rdsvt.dsvt.vasd.voice, dcs_buf+46, 12);
/* send the data to the local gateway/repeater */

@ -72,7 +72,7 @@ typedef struct dsvt_tag {
unsigned char id; // 8 0x20
unsigned char flagb[3]; // 9 0x0 0x1 0x1
unsigned short streamid;// 12
unsigned char counter; // 14 hdr: 0x80 vsad: framecounter (mod 21)
unsigned char ctrl; // 14 hdr: 0x80 vsad: framecounter (mod 21)
union {
struct { // index
unsigned char flag[3]; // 15

@ -390,7 +390,7 @@ int main(int argc, char *argv[])
else
dstr.vpkt.snd_term_id = 0x00;
dstr.vpkt.streamid = htons(streamid_raw);
dstr.vpkt.ctrl = dsvt.counter;
dstr.vpkt.ctrl = dsvt.ctrl;
for (int i=0; i<3; i++)
dstr.vpkt.hdr.flag[i] = dsvt.hdr.flag[i];
memset(dstr.vpkt.hdr.flag+3, ' ', 36);
@ -404,7 +404,7 @@ int main(int argc, char *argv[])
calcPFCS(dstr.pkt_id);
} else {
dstr.remaining = 0x13;
dstr.vpkt.ctrl = dsvt.counter;
dstr.vpkt.ctrl = dsvt.ctrl;
memcpy(dstr.vpkt.vasd.voice, dsvt.vasd.voice, 12);
if ((dstr.vpkt.vasd.text[0] != 0x55) || (dstr.vpkt.vasd.text[1] != 0x2d) || (dstr.vpkt.vasd.text[2] != 0x16)) {

Loading…
Cancel
Save

Powered by TurnKey Linux.