forked from sq7lrx/linDmrMaster
-
Notifications
You must be signed in to change notification settings - Fork 0
/
master_server.h
196 lines (179 loc) · 4.42 KB
/
master_server.h
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
/*
* Linux DMR Master server
Copyright (C) 2014 Wim Hofman
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <syslog.h>
#include <pthread.h>
#include <strings.h>
#include <string.h>
#include <time.h>
#include <stdbool.h>
#include <sqlite3.h>
#include <iconv.h>
#include <netdb.h>
#include <arpa/inet.h>
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
#include <math.h>
#include <regex.h>
#include <ctype.h>
#include <curl/curl.h>
#include <sys/utsname.h>
#include <stdint.h>
struct repeater{
struct sockaddr_in address;
int origServPort;
int sockfd;
bool dmrOnline;
bool rdacOnline;
bool rdacUpdated;
bool intlRefAllow;
int rdacUpdateAttempts;
bool sending[3];
int conference[3];
int conferenceType[3];
int pearRepeater[3];
int pearPos[3];
int id;
time_t pearTimeout;
time_t lastPTPPConnect;
time_t lastDMRConnect;
time_t lastRDACConnect;
unsigned char callsign[17];
unsigned char txFreq[10];
unsigned char shift[7];
unsigned char hardware[11];
unsigned char firmware[14];
unsigned char mode[4];
unsigned char language[50];
unsigned char geoLocation[20];
unsigned char aprsPass[6];
unsigned char aprsBeacon[100];
unsigned char aprsPHG[7];
int autoReflector;
int reflectorTimeout;
int autoConnectTimer;
int upDated;
};
struct idInfo{
int radioId;
char callsign[32];
char name[32];
long aprsTimeStamp;
char aprsSuffix[4];
char aprsBeacon[100];
int aprsSymbol;
int messageStore;
};
struct masterData{
struct sockaddr_in address;
struct sockaddr_in voiceAddress;
int sockfd;
int voiceSockfd;
bool online;
bool sending[3];
};
struct masterInfo{
char ownName[20];
char ownCountryCode[5];
char ownRegion[2];
char eMail[100];
char sMasterIp[100];
char sMasterPort[6];
char announcedCC1[90];
char announcedCC2[90];
int ownCCInt;
int ownRegionInt;
int sMasterTS1GroupCount;
int sMasterTS2GroupCount;
int repTS1GroupCount;
int repTS2GroupCount;
int dynTS1GroupCount;
int dynTS2GroupCount;
int priorityTG[3];
int priorityTimeout;
};
struct ts{
unsigned char repTS1[100];
unsigned char repTS2[100];
unsigned char sMasterTS1[100];
unsigned char sMasterTS2[100];
unsigned char dynamicTS1[100];
unsigned char dynamicTS2[100];
};
struct sockInfo{
struct sockaddr_in address;
int port;
};
struct gpsCoordinates{
int radioId;
unsigned char latitude[9];
unsigned char longitude[10];
unsigned char speed[4];
unsigned char heading[4];
};
struct reflector{
int id;
unsigned char name[55];
int type;
};
typedef enum {VOICE, DATA, IDLE} state;
extern struct repeater repeaterList[100];
extern struct masterData sMaster;
extern struct masterInfo master;
extern struct reflector localReflectors[100];
extern struct ts tsInfo;
extern char databaseServer[50];
extern char databaseUser[20];
extern char databasePassword[20];
extern char database[20];
extern struct sockaddr_in discardList[100];
extern int highestRepeater;
extern int servicePort;
extern int dmrPort;
extern int baseDmrPort;
extern int rdacPort;
extern int baseRdacPort;
extern int maxRepeaters;
extern int echoId;
extern int echoSlot;
extern int rrsGpsId;
extern state dmrState[3];
extern time_t voiceIdleTimer[3];
extern int (*sMasterTS1List)[2];
extern int (*sMasterTS2List)[2];
extern int (*repTS1List)[2];
extern int (*repTS2List)[2];
extern int (*dynTS1List)[2];
extern int (*dynTS2List)[2];
extern int ownCCInt;
extern int ownRegionInt;
extern char version[5];
extern sqlite3 *db;
extern char page[50];
extern char aprsUrl[100];
extern char aprsPort[7];
extern int aprsSockFd;
extern int numReflectors;
extern int masterDmrId;
extern int debug;
extern int versionMismatch;
extern int dynTg[3];
extern time_t dynTgTimeout[3];