1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
|
//
// Common definitons for Pactor-like Modules
#include "kernelresource.h"
#include "rigcontrol.h"
#define MAXBLOCK 4096
#define MAXFREQS 20 // RigControl freqs to scan
extern char HFCTEXT[81];
extern int HFCTEXTLEN;
extern HANDLE hInstance;
extern HMENU hMainFrameMenu;
extern HMENU hWndMenu;
void BuildDevicePage(struct TNCINFO * TNC);
/*
struct WL2KInfo
{
struct WL2KInfo * Next;
char * Host;
short WL2KPort;
char RMSCall[10];
char BaseCall[10];
char GridSquare[7];
char Times[80];
char ServiceCode[17];
BOOL UseRigCtrlFreqs;
char WL2KFreq[12];
char WL2KMode; // WL2K reporting mode
char WL2KModeChar; // W or N
BOOL DontReportNarrowOnWideFreqs;
// char NARROWMODE;
// char WIDEMODE; // Mode numbers to report to WL2K
// struct WL2KInfo WL2KInfoList[MAXFREQS]; // Freqs for sending to WL2K
int Freq;
char Bandwidth;
// char * TimeList; // eg 06-10,12-15
int mode; // see below (an integer)
int baud; // see below (an integer)
int power; // actual power if known, default to 100 for HF, 30 for VHF/UHF (an integer)
int height; // antenna height in feet if known, default to 25
int gain; // antenna gain if known, default to 0
int direction; // primary antenna direction in degrees if known, use 000 for omni (an integer)
BOOL RPonPTC; // Set if scanning for Robust Packet on a PTC
};
*/
#pragma pack(1)
// AGWPE Header Structure
struct AGWHEADER
{
UCHAR Port;
UCHAR filler1[3];
char DataKind;
UCHAR filler2;
unsigned char PID;
UCHAR filler3;
unsigned char callfrom[10];
unsigned char callto[10];
int DataLength;
int reserved;
};
#pragma pack()
// Telnet Server User Record
struct UserRec
{
char * Callsign;
char * UserName;
char * Password;
char * Appl; // Autoconnect APPL
BOOL Secure; // Authorised User
};
struct LOCALNET
{
struct LOCALNET * Next;
uint32_t Network;
uint32_t Mask;
};
#define MaxCMS 10 // Number of addresses we can keep - currently 4 are used.
struct TCPINFO
{
int NumberofUsers;
struct UserRec ** UserRecPtr;
int CurrentConnections;
struct UserRec RelayUser;
int CurrentSockets;
int TCPPort;
int FBBPort[100];
int RelayPort;
int HTTPPort;
int APIPort;
int TriModePort;
int SyncPort;
int SNMPPort;
int DRATSPort;
int CMDPort[33];
int NETROMPort;
char RELAYHOST[64];
char CMSServer[64];
BOOL FallbacktoRelay; // Use Relsy if can't connect to CMS
BOOL IPV4; // Allow Connect using IPV4
BOOL IPV6; // Allow Connect using IPV6
BOOL CMS; // Allow Connect to CMS
BOOL CMSOK; // Internet link is ok.
BOOL UseCachedCMSAddrs;
struct in_addr CMSAddr[MaxCMS];
BOOL CMSFailed[MaxCMS]; // Set if connect to CMS failed.
char * CMSName[MaxCMS]; // Reverse DNS Name of Server
int NumberofCMSAddrs;
int NextCMSAddr; // Round Robin Pointer
int CheckCMSTimer; // CMS Poll Timer
char SecureCMSPassword[80]; // For Secure CMS Signin
char GatewayCall[10]; // Call for CMS access
char GatewayLoc[10]; // Loc - Needed to report Hybrid Mode
int ReportHybrid; // Report as Hybrod Station
char * HybridServiceCode;
char * HybridFrequencies;
char * HybridCoLocatedRMS;
BOOL DisconnectOnClose;
char PasswordMsg[100];
char cfgHOSTPROMPT[100];
char cfgCTEXT[300];
char cfgLOCALECHO[100];
int MaxSessions;
char LoginMsg[100];
char RelayAPPL[20];
char SyncAPPL[20];
SOCKET TCPSock;
SOCKET FBBsock[100];
SOCKET Relaysock;
SOCKET HTTPSock;
SOCKET APIsock;
SOCKET TriModeSock;
SOCKET TriModeDataSock;
SOCKET Syncsock;
SOCKET DRATSsock;
SOCKET SNMPsock;
SOCKET NETROMSock;
struct ConnectionInfo * TriModeControlSession;
SOCKET sock6;
SOCKET FBBsock6[100];
SOCKET Relaysock6;
SOCKET HTTPsock6;
SOCKET APIsock6;
SOCKET Syncsock6;
SOCKET DRATSsock6;
SOCKET NETROMSock6;
fd_set ListenSet;
SOCKET maxsock;
HMENU hActionMenu;
HMENU hLogMenu;
HMENU hDisMenu; // Disconnect Menu Handle
HWND hCMSWnd;
int SecureTelnet;
int noWebSocks;
int ReportRelayTraffic; // Send WL2K Reports for Relay Traffic
char * WebTermCSS; // css override for web terminal
struct LOCALNET * LocalNets;
};
struct STREAMINFO
{
// TRANSPORTENTRY * AttachedSession;
void * PACTORtoBPQ_Q; // Frames for BPQ
void * BPQtoPACTOR_Q; // Frames for PACTOR
int FramesOutstanding; // Frames Queued - used for flow control
int FramesQueued; // Frames Queued - used for flow control
BOOL InternalCmd; // Last Command was generated internally
int IntCmdDelay; // To limit internal commands
BOOL CheckingCall; // Set on PTC if waiting for I response after a Connect RXed
BOOL Attached; // Set what attached to a BPQ32 stream
BOOL Connected; // When set, all data is passed as data instead of commands
BOOL Connecting; // Set when Outward Connect in progress
BOOL Disconnecting; // Set when disconnect in progress
// Used when appplication disconnects the bpq session, and
// prevents new attaches while a dirty disconnect is in progress
int DisconnectingTimeout; // A hard disconnect occurs if this expires before the disconnect complete
int ReportDISC; // Need to report an incoming DISC to kernel
BOOL DiscWhenAllSent; // Close session when all msgs have been sent to node
BOOL ARQENDSent; // Set when V4 ARQEND Sent
int DEDStream; // Stream number for DED interface (same as index except for pactor)
char MyCall[10] ; // Call we are using
char RemoteCall[10]; // Callsign
char callingCall[10]; // for reporting. Link and Our calls depand on which end connected
char receivingCall[10]; // for reporting. Link and Our calls depand on which end connected
char Direction[4]; // In or Out
char AGWKey[21]; // Session Key for AGW Session Based Drivers
time_t ConnectTime; // Time connection made
time_t AttachTime;
int bytesTXed;
int BytesAcked;
int bytesRXed;
int PacketsSent;
int BytesResent;
int BytesOutstanding; // For Packet Channels
UCHAR PTCStatus0; // Status Bytes
UCHAR PTCStatus1; // Status Bytes
UCHAR PTCStatus2; // Status Bytes
UCHAR PTCStatus3; // Status Bytes
char * CmdSet; // A series of commands to send to the TNC
char * CmdSave; // Base address for free
struct ConnectionInfo * ConnectionInfo; // TCP Server Connection Info
int TimeInRX; // Too long in send mode timer
int NeedDisc; // Timer to send DISC if appl not available
BOOL NoCMSFallback; // Dont use relay if CMS not available
struct ARQINFO * ARQInfo; // FLDIGI/FLARQ Stream Mode Specific Data
HWND xIDC_MYCALL;
HWND xIDC_DESTCALL;
HWND xIDC_STATUS;
HWND xIDC_SEND;
HWND xIDC_RXED;
HWND xIDC_RESENT;
HWND xIDC_ACKED;
HWND xIDC_DIRN;
int RelaySyncStream;
int VaraACMode;
};
typedef struct AGWINFO
{
// Fields for AGW Session based Ports (eg UZ7HO Modem)
struct AGWHEADER TXHeader;
struct AGWHEADER RXHeader;
int MaxSessions;
int ConnTimeOut;
int PollDelay;
time_t LastParamTime;
#ifdef WIN32
// For selecting UZ7HO Mode and Freq
COMBOBOXINFO cbinfo; // UZ7HO Modem Combo Box info
HWND hFreq; // UZ7HO Frequency Box
HWND hSpin; // UZ7HO Spin Button
#endif
int isQTSM; // Flag to Identify QtSM
int CenterFreq;
int Modem; // Modem number in list
char ModemName[20];
unsigned char Version[4];
unsigned char fx25Flags;
unsigned char il2pFlags;
unsigned char il2pcrc;
} *PAGWINFO;
typedef struct ARQINFO
{
// Fields for FLDIGI/FLARQ Ports
// Max window is 64, though often will use less
char OurStream;
char FarStream;
PMSGWITHLEN TXHOLDQ[64]; // Frames waiting ACK
PMSGWITHLEN RXHOLDQ[64]; // Frames waiting missing frames.
int TXWindow;
int RXWindow;
int MaxBlock; // Max sending block size
int TXSeq;
int TXLastACK; // Last frame ACK'ed
int RXHighest;
int RXNext;
int RXNoGaps;
int Retries;
int NoAckRetries; // Status received but no data acked
int ARQTimer;
int ARQState;
#define ARQ_ACTIVE 1 // Have a session of some type
int ARQTimerState;
#define ARQ_CONNECTING 1
#define ARQ_CONNECTACK 2
#define ARQ_DISC 3
#define ARQ_WAITACK 4
#define ARQ_WAITDATA 5 // Waiting for more data before polling
char LastMsg[80]; // Last message sent that expects an ack
int LastLen;
char TXMsg[80]; // Message to aend after TXDELAY
int TXLen;
int TurnroundTimer; // RX to TX delay.
int TXDelay;
} *ARQINFO;
typedef struct FLINFO
{
// Fields for MPSK Session Ports )
BOOL TX; // Set when FLDigi is transmitting
char DefaultMode[64]; // Mode to return to after session
int DefaultFreq; // Freq to return to after session
BOOL Beacon; // Use ALE Beacons
char LastXML[128]; // Last XML Request Sent
int XMLControl; // Controlls polling FLDigi by XML
int CmdControl; // Controlls polling FLDigi by KISS Command
BOOL FLARQ; // Connection from FLARQ
BOOL Busy;
BOOL CONOK; // Allow incoming connects
BOOL KISSMODE; // Using KISS instead of socket interface
BOOL RAW; // Raw (ARQ Socket or KISS RAW, depening on above)
int CenterFreq;
char CurrentMode[20]; // Mode to return to after session
int Responding; // If FLDigi is responding to conmands
BOOL MCASTMODE; // If port is in MCAST RX MOde
} *FLINFO;
typedef struct MPSKINFO
{
// Fields for MPSK Session Ports )
int ConnTimeOut;
BOOL TX; // Set when Multipsk is transmitting
char DefaultMode[20]; // Mode to return to after session
BOOL Beacon; // Use ALE Beacons
int MaxSessions;
} *MPSKINFO;
struct FreeDataINFO
{
int startingTNC;
int TNCRunning;
int Conecting;
int Connected;
char ourCall[10];
char toCall[10];
char farCall[10]; // TNC Call
char useBaseCall; // Use base call (without ssid) for TNC Call
char * Capture; // Capture Device Name
char * Playback; // Playback Device Name
char * hamlibHost;
int hamlibPort;
unsigned char toSendData[8192]; // Buffer data from node for more efficiency
int toSendCount;
int toSendTimeout;
unsigned char toSendMsg[256]; // Buffer data from node for more efficiency
int toSendMsgCount;
int toSendMsgTimeout;
char * RXDir; // Directory for Received Files
int CONOK; // Virtual Lisren Flag
int Chat; // In Chat Mode
char ChatCall[10];
int needPoll; // Set if get data needed
int arqstate; // 1 = Disc / 2 - connecting 3 - connected
int TuningRange; // Must be 50, 100, 150, 200, 250
int LimitBandWidth;
int TXLevel;
int Explorer; // Enable reporting to Freedata Explorer
char SSIDList[256];
char * SSIDS[16];
};
struct sixPackInfo;
typedef struct TNCINFO
{
HWND hDlg; // Status Window Handle
int (FAR * WebWindowProc)(struct TNCINFO * TNC, char * Buff, BOOL LOCAL); // Routine to build web status window
int WebWinX;
int WebWinY; // Size of window
char * WebBuffer; // Buffer for logs
int RigControlRow; // Rig Control Line in Dialog
struct _EXTPORTDATA * PortRecord; // BPQ32 port record for this port
struct RIGINFO * RIG; // Pointer to Rig Control RIG record for RX or Both
struct RIGINFO * TXRIG; // Pointer to Rig Control RIG record for TX
char * InitScript; // Initialisation Commands
int InitScriptLen; // Length
time_t SessionTimeLimit; // Optional limit to total session time
time_t DefaultSessionTimeLimit; // Configured value
time_t AttachTimeLimit; // to trap port left attached for a long time without other activity
time_t AttachTime;
int Hardware; // Hardware Type
#define H_WINMOR 1
#define H_SCS 2
#define H_KAM 3
#define H_AEA 4
#define H_HAL 5
#define H_TELNET 6
#define H_TRK 7
#define H_TRKM 7
#define H_V4 8
#define H_UZ7HO 9
#define H_MPSK 10
#define H_FLDIGI 11
#define H_UIARQ 12
#define H_ARDOP 13
#define H_VARA 14
#define H_SERIAL 15
#define H_KISSHF 16
#define H_WINRPR 17
#define H_HSMODEM 18
#define H_FREEDATA 19
#define H_SIXPACK 20
int Port; // BPQ Port Number
struct RIGINFO DummyRig; // Used if not using Rigcontrol
BOOL Minimized; // Start Minimized flag
void * WINMORtoBPQ_Q; // Frames for BPQ, indexed by BPQ Port
void * BPQtoWINMOR_Q; // Frames for WINMOR. indexed by WINMOR port. Only used it TCP session is blocked
SOCKET TCPSock; // Control Socket
SOCKET TCPDataSock; // Data Socket
SOCKET PacketSock; // Packet Over TCP (ARDOP)
char * WINMORSignon; // Pointer to message for secure signin
char * HostName; // WINMOR Host - may be dotted decimal or DNS Name
int TCPPort; //
int PacketPort; // Packet Over TCP (ARDOP)
char * ApplCmd; // Application to connect to on incoming connect (null = leave at command handler)
BOOL SwallowSignon; // Set to suppress *** connected to APPL
union
{
UCHAR TCPBuffer[1000]; // For converting byte stream to messages
UCHAR DEDBuffer[1000]; // For converting byte stream to messages
UCHAR KISSBuffer[1000]; // For KISS over Host Mode
};
UCHAR * ARDOPBuffer; // Needs to be pretty big, so Malloc
UCHAR * ARDOPDataBuffer; // Needs to be pretty big, so Malloc
int InputLen; // Data we have already = Offset of end of an incomplete packet;
int DataInputLen; // Data we have already = Offset of end of an incomplete packet;
int KISSInputLen; // Data we have already = Offset of end of an incomplete packet;
int ESCFLAG; // KISS Escape received
int MSGCOUNT; // DED WORKING FIELD
int MSGLENGTH; // DED Msg Len
int MSGCHANNEL; // DED Msg Channel Number
int MSGTYPE; // DED Msg Type
int HOSTSTATE; // ded HOST state machine
BOOL StartSent; // Codec Start send (so will get a disconnect)
int ConnectPending; // Set if Connect Pending Received. If so, mustn't allow freq change.
BOOL GavePermission; // Set if we allowed freq change
BOOL DiscPending; // Set if Disconnect Pending Received. So we can time out stuck in Disconnecting
BOOL HadConnect; // Flag to say have been in session
BOOL FECMode; // In FEC Mode
BOOL FEC1600; // Use 1600 Hz FEC Mode
int FECIDTimer; // Time in FEC Mode. Used to trigger ID broadcasts
BOOL RestartAfterFailure;
BOOL StartInRobust; // For WINMOR, set to Robust Mode for first few packets
int Busy; // Channel Busy Timer/Counter . Non-zero = Busy
int BusyFlags; // Channel Busy Flags
#define CDBusy 1 // For WINMOR - reported busy (set till reported clear)
#define PTTBusy 2 // PTT Active
BOOL FECPending; // Need an FEC Send when channel is next idle
time_t lasttime;
BOOL CONNECTING; // TCP Session Flags
BOOL CONNECTED;
BOOL Alerted; // Connect Failed Prompt sent
BOOL DATACONNECTING;
BOOL DATACONNECTED;
BOOL TNCCONNECTING; // For FreeData
BOOL TNCCONNECTED;
BOOL QtSMConnected;
char NodeCall[10]; // Call we listen for (PORTCALL or NODECALL
char CurrentMYC[10]; // Save current call so we don't change it unnecessarily
char * LISTENCALLS; // Calls TNC will respond to (currently only for VARA)
char TargetCall[10]; // Call incoming connect is addressed to (for appl call support)
struct sockaddr_in destaddr;
struct sockaddr_in Datadestaddr;
int PTTMode; // PTT Mode Flags
int PTTState; // Current State
uint64_t PTTActivemS; // For Stats
uint64_t PTTonTime; //
uint64_t BusyActivemS; // For channel busy stats
uint64_t BusyonTime;
char PTTOn[60]; // Port override of RIGCONTROL config
char PTTOff[60];
int PTTOnLen;
int PTTOffLen;
int TXRadio; // Rigcontrol Radio Number for TX
int RXRadio; // Rigcontrol Radio Number for RX
long long int TXFreq; // Freq to set on tx before ptt
double ActiveTXFreq; // Freq to set on tx after attach
double ActiveRXFreq; // Freq to set on rx after attach
double DefaultTXFreq; // Freq to set on tx after close
double DefaultRXFreq; // Freq to set on rx after close
char ** DisconnectScript; // May replace above 2 params
int TXOffset; // Correction to TXFreq
int PID; // Process ID for Software TNC
HWND hWnd; // Main window handle for Software TNC
char * CaptureDevices;
char * PlaybackDevices;
char * ProgramPath;
BOOL WeStartedTNC;
int Restarts; // TNC Kill/Restarts done
time_t LastRestart;
int TimeSinceLast; // Time since last message from TNC (10ths of a sec)
int HeartBeat;
// int Interlock; // Port Interlock Group
HWND hMonitor; // Handle to Monitor control
// HMENU hPopMenu; // Actions Menu Handle
int MaxConReq; // For ARDOP
int BusyHold; // Hold Time from SCS reporting channel free till we call
int BusyWait; // Time to wait for clear channel before connect
BOOL OverrideBusy;
int BusyDelay; // Timer for busy timeout
int AutoStartDelay; // Time to wait for TNC to start
char * ConnectCmd; // Saved command if waiting for busy to clear
BOOL UseAPPLCalls; // Robust Packet to use Applcalls
BOOL UseAPPLCallsforPactor; // Pactor to use Applcalls
// Fields for reporting to WL2K Map
struct WL2KInfo * WL2K;
/*
char * Host;
short WL2KPort;
int UpdateWL2KTimer;
BOOL UpdateWL2K;
char RMSCall[10];
char BaseCall[10];
char GridSquare[7];
char Comment[80];
char ServiceCode[17];
BOOL UseRigCtrlFreqs;
char WL2KFreq[12];
char WL2KModeChar; // W or N
BOOL DontReportNarrowOnWideFreqs;
// char NARROWMODE;
// char WIDEMODE; // Mode numbers to report to WL2K
struct WL2KInfo WL2KInfoList[MAXFREQS]; // Freqs for sending to WL2K
*/
char WL2KMode; // WL2K reporting mode
struct STREAMINFO Streams[27]; // 0 is Pactor 1 - 10 are ax.25.
int LastStream; // Last one polled for status or send
void * BPQtoRadio_Q; // Frames to Rig Interface
void * RadiotoBPQ_Q; // Frames from Rig Interface
void * KISSTX_Q; // Frames to Host Mode KISS interface
struct PORTCONTROL * VirtualPORT; // Pointer to Virtual Packet Port of Host Mode KISS
char * InitPtr; // Next Command
int ReinitState; // Reinit State Machine
int ReinitCount; // Count for DED Recovery
int TermReinitCount; // Count for DED Term Mode Recovery
BOOL TNCOK; // TNC is reponding
int FramesOutstanding; // Frames Queued - used for flow control
BOOL InternalCmd; // Last Command was generated internally
int IntCmdDelay; // To limit internal commands
HANDLE hDevice;
int ReopenTimer; // Used to reopen device if failed (eg USB port removed)
BOOL HostMode; // Set if in DED Host Mode
// BOOL CRCMode; // Set if using SCS Extended DED Mode (JHOST4)
BOOL UsingTermMode; // Set if tnc should be left in term mode
int Timeout; // Timeout response counter
int Retries;
int Window; // Window Size for ARQ
UCHAR TXBuffer[500]; // Last message sent - saved for Retry
int TXLen; // Len of last sent
UCHAR RXBuffer[520]; // Message being received - may not arrive all at once
UINT RXLen; // Data in RXBUffer
UCHAR Toggle; // Sequence bit
int Buffers; // Free buffers in TNC
BOOL WantToChangeFreq; // Request from Scanner to Change
int OKToChangeFreq; // 1 = SCS Says OK to change, -1 = Dont Change zero = still waiting
BOOL DontWantToChangeFreq; // Change done - ok to SCS
BOOL DontReleasePermission; // Hold Permission to prevent calls on this frequency
time_t TimeEnteredSYNCMode; // To detect scan lock when using applcalls on PTC
BOOL SyncSupported; // TNC reports sync
time_t TimeScanLocked; // ditto for TNCs that don't report SYNC
int PTCStatus; // Sync, Idle, Traffic, etc
UCHAR NexttoPoll[20]; // Streams with data outstanding (from General Poll)
BOOL PollSent; // Toggle to ensure we issue a general poll regularly
int StreamtoPoll;
char Bandwidth; // Currently set Mode W or N
int Mode; // Mode Flag
BOOL Dragon; // Set if P4Dragon
BOOL DragonSingle; // Set if P4Dragon using Pactor and Packet on same port
BOOL DragonKISS; // Set if P4Dragon supports sending KISS frames in Hostmode
BOOL EnterExit; // Switching to Term mode to change bandwidth
int PktStream; // Stream in use for Packet when in single port mode
BOOL MaxLevel; // Pactor Level to set for Wide Mode (3 or 4)
int MinLevel; // Mimimum accepted Pactor Level
int MinLevelTimer; // Time left to achieve Min Level
int PacketChannels;
int RobustTime; // For PTC, Spend this part of scan cycle (in 10th secs) in Robust Packet Mode
int SwitchToPactor; // Countdown to switch
BOOL OldMode; // Use PACTOR instead of TOR (for old software)
BOOL VeryOldMode; // Use MYCALL instead of MYPTCALL (for old software)
int Mem1; // Free Bytes (VHF /HF)
int Mem2;
BOOL HFPacket; // Set if HF port is in Packet mode instead of Pactor Mode
BOOL Robust; // Set if SCS Tracker is in Robust Packet mode or WINMOR TNC is in Robust Mode
BOOL RobustDefault; // Set if SCS Tracker default is Robust Packet mode
BOOL ForceRobust; // Don't allow Normal Packet even if scan requests it.
BOOL TeensyRPR; // Teensy RPR TNC - don't send %R
char NormSpeed[8]; // Speed Param for Normal Packet on Tracker
char RobustSpeed[8]; // Speed Param for Robust Packet on Tracker
BOOL RPBEACON; // Send Beacon after each session
int TimeInRX; // Time waiting for ISS before sending
char TXRXState; // Current ISS/IRS State
BOOL NeedPACTOR; // Set if need to send PACTOR to put into Standby Mode
int CmdStream; // Stream last command was issued on
union
{
struct TCPINFO * TCPInfo; // Telnet Server Specific Data
struct AGWINFO * AGWInfo; // AGW Stream Mode Specific Data
struct MPSKINFO * MPSKInfo; // MPSK Stream Mode Specific Data
struct FLINFO * FLInfo; // FLDIGI Stream Mode Specific Data
};
struct ARQINFO * ARQInfo; // FLDIGI/FLARQ Stream Mode Specific Data
BOOL DataBusy; // Waiting for Data Ack - Don't send any more data
BOOL CommandBusy; // Waiting for Command ACK
BOOL TEXTMODE; // Set if AEA in text mode
BOOL NeedTurnRound; // Set if we have sent data, so need to send ctrl/z
BOOL NeedTRANS; // Set if we have to send TRANS when ctrl/z is acked.
char * CmdSet; // A series of commands to send to the TNC
char * CmdSave; // Base address for free
BOOL PktUpdateMap; // Set if Packet MH data to be sent to NodeMap
int DefaultMode;
int CurrentMode; // Used on HAL
char * DefaultRadioCmd; // RADIO command to send at end of session
char * Frequency;
// For Mode Map if no Rigcontrol
// Mode Equates
#define Clover 'C'
#define Pactor 'P'
#define AMTOR 'A'
UCHAR DataBuffer[500]; // Data Chars split from received stream
UCHAR CmdBuffer[500]; // Cmd/Response chars split from received stream
int DataLen; // Data in DataBuffer
int CmdLen; // Data in CmdBuffer
BOOL CmdEsc; // Set if last char rxed was 0x80
BOOL DataEsc; // Set if last char rxed was 0x81
int PollDelay; // Don't poll too often;
int InData; // FLDigi - MCAST <....> received
int InPacket; // FLDigi - SOH or < received.
int MCASTLen; // Data still to get
int DataMode; // How to treat data
#define RXDATA 0x30 // Switch to Receive Data characters
#define TXDATA 0x31 // Switch to Transmit Data characters
#define SECDATA 0x32 // Switch to RX data from secondary port
int TXMode; // Where to send data
#define TXMODEM 0x33 // Send TX data to modem
#define TXSEC 0x34 // Send TX data to secondary port
BOOL XONXOFF; // Set if hardware is using XON/XOFF
double LastFreq; // Used by V4 to see if freq has changed
int ModemCentre; // Modem centre frequency
int ClientHeight;
int ClientWidth;
HWND xIDC_TNCSTATE;
HWND xIDC_COMMSSTATE;
HWND xIDC_MODE;
HWND xIDC_LEDS;
HWND xIDC_TRAFFIC;
HWND xIDC_BUFFERS;
HWND xIDC_CHANSTATE;
HWND xIDC_LEVELS;
HWND xIDC_STATE;
HWND xIDC_TXRX;
HWND xIDC_PROTOSTATE;
HWND xIDC_RESTARTTIME;
HWND xIDC_RESTARTS;
HWND xIDC_PACTORLEVEL;
HWND xIDC_TXTUNE;
HWND xIDC_TXTUNEVAL;
char * WEB_TNCSTATE;
char * WEB_COMMSSTATE;
char * WEB_MODE;
char * WEB_LEDS;
char * WEB_TRAFFIC;
char * WEB_BUFFERS;
char * WEB_CHANSTATE;
char * WEB_STATE;
char * WEB_TXRX;
char * WEB_PROTOSTATE;
char * WEB_RESTARTTIME;
char * WEB_RESTARTS;
char * WEB_PACTORLEVEL;
char * WEB_LEVELS;
char WEB_CHANGED; // Used to speed up refresh when active
char WebSockUsed; // If not set don't build page
char PageChanged; // Set when page could have changed
char * WebPage; // Device Web Page. Used for Websocks refresh
int WebPageLen;
HMENU hMenu;
HMENU hWndMenu;
VOID (* SuspendPortProc) (struct TNCINFO * TNC, struct TNCINFO * ThisTNC);
VOID (* ReleasePortProc) (struct TNCINFO * TNC);
VOID (* ForcedCloseProc) (struct TNCINFO * TNC, int Stream);
time_t WinmorRestartCodecTimer;
int WinmorCurrentMode;
char ARDOPCurrentMode[10];
char ARDOPCommsMode;
char * ARDOPSerialPort; // Have Bus/Device for I2C
int ARDOPSerialSpeed;
BOOL TCPCONNECTED; // ARDOP over TCP Connected
int SlowTimer;
int ARQPorts[32]; // For ARQ over KISS
char * LogPath;
FILE * LogHandle; // Ardop Logging File
FILE * DebugHandle; // Ardop Debug File
char LastLogType; // For split packets
UCHAR * ARDOPAPRS; // Used to reconstruct APRS datagram from FEC packets
int ARDOPAPRSLen;
BOOL WRITELOG; // Enable debug logging
int InputLevelMin; // Sound card levels
int InputLevelMax; // Sound card levels
int DiscardNextOK; // Used by VARA to suppress OK response to LISTEN commands
int SeenCancelPending; // Used by VARA to suppress duplicate cancel pendings
MESSAGE * Monframe; // Used by DED Host for receiving Packet Monitor Frame
// split over 2 packets
struct HSMODEMINFO * HSModemInfo;
struct FreeDataINFO * FreeDataInfo;
int DontRestart; // Don't automatically restart failed TNC
int SendTandRtoRelay; // Send T and R suffix messages to RELAY instead of CMS
double SNR; // S/N Ratio (VARA)
int NetRomMode;
unsigned char * NetRomTxBuffer; // For Netrom over VARA
int NetRomTxLen;
char * NRNeighbour;
int NRCloseTimer;
struct _LINKTABLE * DummyLink; // Simulated link to simplify interface to ax,25 netrom code
struct sixPackPortInfo * sixPack;
char VaraACAllowed; // Set by config
char VaraACMode; // Set by first message received
char VaraModeSet; // Have decicded if VarAC mode or not
char * VARACMsg; // to build message from packets
int VarACTimer; // delayed send timer
size_t VARACSize; // malloc'ed size
} *PTNCINFO;
VOID * zalloc(int len);
BOOL ReadConfigFile(int Port, int ProcLine(char * buf, int Port));
int GetLine(char * buf);
BOOL CreatePactorWindow(struct TNCINFO * TNC, char * ClassName, char * WindowTitle, int RigControlRow, WNDPROC WndProc,
int Width, int Height, VOID ForcedCloseProc(struct TNCINFO * TNC, int Stream));
char * CheckAppl(struct TNCINFO * TNC, char * Appl);
BOOL SendReporttoWL2K(struct TNCINFO * TNC);
struct WL2KInfo * DecodeWL2KReportLine(char * buf);
VOID UpdateMH(struct TNCINFO * TNC, UCHAR * Call, char Mode, char Direction);
VOID UpdateMHEx(struct TNCINFO * TNC, UCHAR * Call, char Mode, char Direction, char * LOC, BOOL Report);
VOID SaveWindowPos(int port);
VOID SaveMDIWindowPos(HWND hWnd, char * RegKey, char * Value, BOOL Minimized);
BOOL ProcessIncommingConnect(struct TNCINFO * TNC, char * Call, int Stream, BOOL SENDCTEXT);
BOOL ProcessIncommingConnectEx(struct TNCINFO * TNC, char * Call, int Stream, BOOL SENDCTEXT, BOOL AllowTR);
VOID ShowTraffic(struct TNCINFO * TNC);
int OpenCOMMPort(struct TNCINFO * conn, char * Port, int Speed, BOOL Quiet);
VOID SendMH(struct TNCINFO * TNC, char * call, char * freq, char * LOC, char * Mode);
VOID MoveWindows(struct TNCINFO * TNC);
static VOID TidyClose(struct TNCINFO * TNC, int Stream);
static VOID ForcedClose(struct TNCINFO * TNC, int Stream);
static VOID CloseComplete(struct TNCINFO * TNC, int Stream);
VOID CheckForDetach(struct TNCINFO * TNC, int Stream, struct STREAMINFO * STREAM,
VOID TidyCloseProc(struct TNCINFO * TNC, int Stream), VOID ForcedCloseProc(struct TNCINFO * TNC, int Stream),
VOID CloseComplete(struct TNCINFO * TNC, int Stream));
BOOL InterlockedCheckBusy(struct TNCINFO * ThisTNC);
extern UINT CRCTAB;
int BPQTRACE(MESSAGE * Msg, BOOL TOAPRS);
static int ProcessLine(char * buf, int Port);
Dll VOID __cdecl Debugprintf(const char * format, ...);
VOID __cdecl Consoleprintf(const char * format, ...);
extern BOOL MinimizetoTray;
int standardParams(struct TNCINFO * TNC, char * buf);
void DecodePTTString(struct TNCINFO * TNC, char * ptr);
int Rig_Command(TRANSPORTENTRY * Session, char * Command);
BOOL Rig_Poll();
VOID Rig_PTT(struct TNCINFO * TNC, BOOL PTTState);
VOID Rig_PTTEx(struct RIGINFO * RIG, BOOL PTTState, struct TNCINFO * TNC);
struct RIGINFO * Rig_GETPTTREC(int Port);
struct ScanEntry ** CheckTimeBands(struct RIGINFO * RIG);
#ifndef LINBPQ
LRESULT CALLBACK PacWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
#endif
#define Report_P1 11
#define Report_P12 12
#define Report_P123 13
#define Report_P2 14
#define Report_P23 15
#define Report_P3 16
#define Report_P1234 17
#define Report_P234 18
#define Report_P34 19
#define Report_P4 20
#define Report_WINMOR500 21
#define Report_WINMOR1600 22
#define Report_Robust 30
#define IOCTL_SERIAL_IS_COM_OPEN CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x800,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_SERIAL_GETDATA CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x801,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SETDATA CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x802,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_CTS CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x803,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_DSR CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x804,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_SERIAL_SET_DCD CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x805,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_SERIAL_CLR_CTS CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x806,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_SERIAL_CLR_DSR CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x807,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_SERIAL_CLR_DCD CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x808,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_BPQ_ADD_DEVICE CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x809,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define IOCTL_BPQ_DELETE_DEVICE CTL_CODE(FILE_DEVICE_SERIAL_PORT,0x80a,METHOD_BUFFERED,FILE_ANY_ACCESS)
#define W98_SERIAL_GETDATA 0x801
#define W98_SERIAL_SETDATA 0x802
|