relay compiles

pull/12/head
Tom Early 7 years ago
parent 4a884b0aa0
commit 18200a73f7

@ -51,7 +51,7 @@
#include "UnixDgramSocket.h" #include "UnixDgramSocket.h"
#include "QnetConfigure.h" #include "QnetConfigure.h"
#define DVAP_VERSION "QnetDVAP-6.0.1" #define DVAP_VERSION "QnetDVAP-6.1.0"
#define CALL_SIZE 8 #define CALL_SIZE 8
#define IP_SIZE 15 #define IP_SIZE 15

@ -57,7 +57,7 @@
#include "QnetConfigure.h" #include "QnetConfigure.h"
#include "QnetGateway.h" #include "QnetGateway.h"
#define IRCDDB_VERSION "QnetGateway-9.0.0" #define IRCDDB_VERSION "QnetGateway-8.1.0"
extern void dstar_dv_init(); extern void dstar_dv_init();
extern int dstar_dv_decode(const unsigned char *d, int data[3]); extern int dstar_dv_decode(const unsigned char *d, int data[3]);

@ -44,7 +44,7 @@
#include "QnetTypeDefs.h" #include "QnetTypeDefs.h"
#include "QnetConfigure.h" #include "QnetConfigure.h"
#define ITAP_VERSION "QnetITAP-2.0.0" #define ITAP_VERSION "QnetITAP-2.1.0"
std::atomic<bool> CQnetITAP::keep_running(true); std::atomic<bool> CQnetITAP::keep_running(true);

@ -52,7 +52,7 @@
#include "QnetConfigure.h" #include "QnetConfigure.h"
#include "QnetLink.h" #include "QnetLink.h"
#define LINK_VERSION "QnetLink7.0.3" #define LINK_VERSION "QnetLink7.1.0"
std::atomic<bool> CQnetLink::keep_running(true); std::atomic<bool> CQnetLink::keep_running(true);

@ -45,7 +45,7 @@
#include "QnetTypeDefs.h" #include "QnetTypeDefs.h"
#include "QnetConfigure.h" #include "QnetConfigure.h"
#define MODEM_VERSION "QnetModem-0.0.0" #define MODEM_VERSION "QnetModem-0.1.0"
#define MAX_RESPONSES 30 #define MAX_RESPONSES 30
std::atomic<bool> CQnetModem::keep_running(true); std::atomic<bool> CQnetModem::keep_running(true);

@ -36,7 +36,7 @@
#include "QnetTypeDefs.h" #include "QnetTypeDefs.h"
#include "QnetConfigure.h" #include "QnetConfigure.h"
#define RELAY_VERSION "QnetRelay-1.0.3" #define RELAY_VERSION "QnetRelay-1.1.0"
std::atomic<bool> CQnetRelay::keep_running(true); std::atomic<bool> CQnetRelay::keep_running(true);
@ -193,7 +193,7 @@ bool CQnetRelay::Run(const char *cfgfile)
//printf("read %d bytes from MMDVMHost\n", (int)len); //printf("read %d bytes from MMDVMHost\n", (int)len);
if (ProcessMMDVM(len, buf)) if (ProcessMMDVM(len, buf))
break; break;
} else if (0 == ::memcmp(buf, "DSTR", 4)) { } else if (0 == ::memcmp(buf, "DSVT", 4)) {
//printf("read %d bytes from MMDVMHost\n", (int)len); //printf("read %d bytes from MMDVMHost\n", (int)len);
if (ProcessGateway(len, buf)) if (ProcessGateway(len, buf))
break; break;
@ -229,23 +229,23 @@ int CQnetRelay::SendTo(const int fd, const unsigned char *buf, const int size, c
bool CQnetRelay::ProcessGateway(const int len, const unsigned char *raw) bool CQnetRelay::ProcessGateway(const int len, const unsigned char *raw)
{ {
if (29==len || 58==len) { //here is dstar data if (27==len || 56==len) { //here is dstar data
SDSTR dstr; SDSVT dsvt;
::memcpy(dstr.pkt_id, raw, len); // transfer raw data to SDSTR struct ::memcpy(dsvt.title, raw, len); // transfer raw data to SDSVT struct
SDSRP dsrp; // destination SDSRP dsrp; // destination
// fill in some inital stuff // fill in some inital stuff
::memcpy(dsrp.title, "DSRP", 4); ::memcpy(dsrp.title, "DSRP", 4);
dsrp.voice.id = dstr.vpkt.streamid; // voice or header is the same position dsrp.voice.id = dsvt.streamid; // voice or header is the same position
dsrp.voice.seq = dstr.vpkt.ctrl; // ditto dsrp.voice.seq = dsvt.ctrl; // ditto
if (29 == len) { // write an AMBE packet if (27 == len) { // write an AMBE packet
dsrp.tag = 0x21U; dsrp.tag = 0x21U;
if (log_qso && (dsrp.voice.seq & 0x40)) if (log_qso && (dsrp.voice.seq & 0x40))
printf("Sent DSRP end of streamid=%04x\n", ntohs(dsrp.voice.id)); printf("Sent DSRP end of streamid=%04x\n", ntohs(dsrp.voice.id));
if ((dsrp.voice.seq & ~0x40U) > 20) if ((dsrp.voice.seq & ~0x40U) > 20)
printf("DEBUG: ProcessGateway: unexpected voice sequence number %d\n", dsrp.voice.seq); printf("DEBUG: ProcessGateway: unexpected voice sequence number %d\n", dsrp.voice.seq);
dsrp.voice.err = 0; // NOT SURE WHERE TO GET THIS FROM THE INPUT buf dsrp.voice.err = 0; // NOT SURE WHERE TO GET THIS FROM THE INPUT buf
memcpy(dsrp.voice.ambe, dstr.vpkt.vasd.voice, 12); memcpy(dsrp.voice.ambe, dsvt.vasd.voice, 12);
int ret = SendTo(msock, dsrp.title, 21, MMDVM_IP, MMDVM_IN_PORT); int ret = SendTo(msock, dsrp.title, 21, MMDVM_IP, MMDVM_IN_PORT);
if (ret != 21) { if (ret != 21) {
printf("ERROR: ProcessGateway: Could not write AMBE mmdvmhost packet\n"); printf("ERROR: ProcessGateway: Could not write AMBE mmdvmhost packet\n");
@ -257,14 +257,14 @@ bool CQnetRelay::ProcessGateway(const int len, const unsigned char *raw)
// printf("DEBUG: ProcessGateway: unexpected pkt.header.seq %d, resetting to 0\n", pkt.header.seq); // printf("DEBUG: ProcessGateway: unexpected pkt.header.seq %d, resetting to 0\n", pkt.header.seq);
dsrp.header.seq = 0; dsrp.header.seq = 0;
} }
//memcpy(dsrp.header.flag, dstr.vpkt.hdr.flag, 41); //memcpy(dsrp.header.flag, dsvt.hdr.flag, 41);
memcpy(dsrp.header.flag, dstr.vpkt.hdr.flag, 3); memcpy(dsrp.header.flag, dsvt.hdr.flag, 3);
memcpy(dsrp.header.r1, dstr.vpkt.hdr.r1, 8); memcpy(dsrp.header.r1, dsvt.hdr.rpt1, 8);
memcpy(dsrp.header.r2, dstr.vpkt.hdr.r2, 8); memcpy(dsrp.header.r2, dsvt.hdr.rpt2, 8);
memcpy(dsrp.header.ur, dstr.vpkt.hdr.ur, 8); memcpy(dsrp.header.ur, dsvt.hdr.urcall, 8);
memcpy(dsrp.header.my, dstr.vpkt.hdr.my, 8); memcpy(dsrp.header.my, dsvt.hdr.mycall, 8);
memcpy(dsrp.header.nm, dstr.vpkt.hdr.nm, 4); memcpy(dsrp.header.nm, dsvt.hdr.sfx, 4);
memcpy(dsrp.header.pfcs, dstr.vpkt.hdr.pfcs, 2); memcpy(dsrp.header.pfcs, dsvt.hdr.pfcs, 2);
int ret = SendTo(msock, dsrp.title, 49, MMDVM_IP, MMDVM_IN_PORT); int ret = SendTo(msock, dsrp.title, 49, MMDVM_IP, MMDVM_IN_PORT);
if (ret != 49) { if (ret != 49) {
printf("ERROR: ProcessGateway: Could not write Header mmdvmhost packet\n"); printf("ERROR: ProcessGateway: Could not write Header mmdvmhost packet\n");
@ -297,48 +297,44 @@ bool CQnetRelay::ProcessMMDVM(const int len, const unsigned char *raw)
return false; return false;
} }
SDSTR dstr; // destination SDSVT dsvt; // destination
// sets most of the params // sets most of the params
::memcpy(dstr.pkt_id, "DSTR", 4); ::memcpy(dsvt.title, "DSVT", 4);
dstr.counter = htons(COUNTER++); dsvt.config = (len==49) ? 0x10U : 0x20U;
dstr.flag[0] = 0x73; memset(dsvt.flaga, 0U, 3U);
dstr.flag[1] = 0x12; dsvt.id = 0x20U;
dstr.flag[2] = 0x0; dsvt.flagb[0] = 0x0U;
dstr.vpkt.icm_id = 0x20; dsvt.flagb[1] = 0x1U;
dstr.vpkt.dst_rptr_id = 0x0; dsvt.flagb[2] = ('B'==RPTR_MOD) ? 0x1U : (('C'==RPTR_MOD) ? 0x2U : 0x3U);
dstr.vpkt.snd_rptr_id = 0x1; dsvt.streamid = id;
dstr.vpkt.snd_term_id = ('B'==RPTR_MOD) ? 0x1 : (('C'==RPTR_MOD) ? 0x2 : 0x3);
dstr.vpkt.streamid = id;
if (49 == len) { // header if (49 == len) { // header
dstr.remaining = 0x30; dsvt.ctrl = 0x80;
dstr.vpkt.ctrl = 0x80; //memcpy(dsvt.hdr.flag, dsrp.header.flag, 41);
//memcpy(dstr.vpkt.hdr.flag, dsrp.header.flag, 41); memcpy(dsvt.hdr.flag, dsrp.header.flag, 3);
memcpy(dstr.vpkt.hdr.flag, dsrp.header.flag, 3); memcpy(dsvt.hdr.rpt1, dsrp.header.r1, 8);
memcpy(dstr.vpkt.hdr.r1, dsrp.header.r1, 8); memcpy(dsvt.hdr.rpt2, dsrp.header.r2, 8);
memcpy(dstr.vpkt.hdr.r2, dsrp.header.r2, 8); memcpy(dsvt.hdr.urcall, dsrp.header.ur, 8);
memcpy(dstr.vpkt.hdr.ur, dsrp.header.ur, 8); memcpy(dsvt.hdr.mycall, dsrp.header.my, 8);
memcpy(dstr.vpkt.hdr.my, dsrp.header.my, 8); memcpy(dsvt.hdr.sfx, dsrp.header.nm, 4);
memcpy(dstr.vpkt.hdr.nm, dsrp.header.nm, 4); memcpy(dsvt.hdr.pfcs, dsrp.header.pfcs, 2);
memcpy(dstr.vpkt.hdr.pfcs, dsrp.header.pfcs, 2); if (56 != Modem2Gate.Write(dsvt.title, 56)) {
if (58 != Modem2Gate.Write(dstr.pkt_id, 58)) {
printf("ERROR: ProcessMMDVM: Could not write gateway header packet\n"); printf("ERROR: ProcessMMDVM: Could not write gateway header packet\n");
return true; return true;
} }
if (log_qso) if (log_qso)
printf("Sent DSTR streamid=%04x ur=%.8s r1=%.8s r2=%.8s my=%.8s/%.4s\n", ntohs(dstr.vpkt.streamid), dstr.vpkt.hdr.ur, dstr.vpkt.hdr.r1, dstr.vpkt.hdr.r2, dstr.vpkt.hdr.my, dstr.vpkt.hdr.nm); printf("Sent DSVT streamid=%04x ur=%.8s r1=%.8s r2=%.8s my=%.8s/%.4s\n", ntohs(dsvt.streamid), dsvt.hdr.urcall, dsvt.hdr.rpt1, dsvt.hdr.rpt2, dsvt.hdr.mycall, dsvt.hdr.sfx);
} else if (21 == len) { // ambe } else if (21 == len) { // ambe
dstr.remaining = 0x16; dsvt.ctrl = dsrp.header.seq;
dstr.vpkt.ctrl = dsrp.header.seq; memcpy(dsvt.vasd.voice, dsrp.voice.ambe, 12);
memcpy(dstr.vpkt.vasd.voice, dsrp.voice.ambe, 12);
if (29 != Modem2Gate.Write(dstr.pkt_id, 29)) { if (27 != Modem2Gate.Write(dsvt.title, 27)) {
printf("ERROR: ProcessMMDVM: Could not write gateway voice packet\n"); printf("ERROR: ProcessMMDVM: Could not write gateway voice packet\n");
return true; return true;
} }
if (log_qso && dstr.vpkt.ctrl&0x40) if (log_qso && dsvt.ctrl&0x40)
printf("Sent DSTR end of streamid=%04x\n", ntohs(dstr.vpkt.streamid)); printf("Sent DSVT end of streamid=%04x\n", ntohs(dsvt.streamid));
} }
} else if (len < 65 && dsrp.tag == 0xAU) { } else if (len < 65 && dsrp.tag == 0xAU) {
// printf("MMDVM Poll: '%s'\n", (char *)mpkt.poll_msg); // printf("MMDVM Poll: '%s'\n", (char *)mpkt.poll_msg);

Loading…
Cancel
Save

Powered by TurnKey Linux.