-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathZoneModule.cpp
112 lines (87 loc) · 2.26 KB
/
ZoneModule.cpp
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
#include "ZoneModule.h"
#include "DStarTools.h"
#include <string.h>
ZoneModule::ZoneModule(config_setting_t* setting, GateLink* link, GateModule* next) :
link(link),
next(next),
context(NULL)
{
const char* call = NULL;
const char* server = NULL;
const char* section = config_setting_name(setting);
size_t length = strlen(section);
name = section[length - 1];
config_setting_lookup_string(setting, "call", &call);
config_setting_lookup_string(setting, "server", &server);
if ((link != NULL) &&
(call != NULL) &&
(server != NULL))
{
char letter = name - '0' + 'A';
int port = link->getDefaultPort();
context = new GateContext(letter, call, server, port);
}
}
ZoneModule::~ZoneModule()
{
if (context != NULL)
delete context;
}
char ZoneModule::getName()
{
return name;
}
bool ZoneModule::isActive()
{
return (context != NULL);
}
GateModule* ZoneModule::getNext()
{
return next;
}
GateLink* ZoneModule::getLink()
{
return link;
}
GateContext* ZoneModule::getContext()
{
return context;
}
void ZoneModule::addDescriptors(int type, fd_set* read, fd_set* write, fd_set* except)
{
}
void ZoneModule::processDescriptors(int type, fd_set* read, fd_set* write, fd_set* except)
{
}
bool ZoneModule::findRoute(const char* call, struct DStarRoute* route, struct in_addr* address)
{
const char* reflector = context->getCall();
memcpy(route->repeater1, reflector, LONG_CALLSIGN_LENGTH);
memcpy(route->repeater2, reflector, LONG_CALLSIGN_LENGTH);
memcpy(route->yourCall, CQCQCQ, LONG_CALLSIGN_LENGTH);
route->repeater1[MODULE_NAME_POSITION] = 'G';
*address = context->getAddress()->sin_addr;
return true;
}
bool ZoneModule::verifyRepeater(const char* call)
{
return
(CompareDStarCall(call, link->getCall(), COMPARE_SKIP_MODULE) == 0) &&
(GetDStarModule(call) == context->getModule());
}
bool ZoneModule::verifyAddress(const struct in_addr& address)
{
return (context->getAddress()->sin_addr.s_addr == address.s_addr);
}
void ZoneModule::publishHeard(const struct DStarRoute& route, const char* addressee, const char* text)
{
}
void ZoneModule::publishHeard(const struct DStarRoute& route, uint16_t number)
{
}
void ZoneModule::doBackgroundActivity(int type)
{
}
void ZoneModule::handleCommand(const char* command)
{
}