Forwerders are declared by the ClientList file.

Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
tomoaki
2018-08-13 21:28:51 +09:00
parent f216abd97e
commit 97cffe4573
15 changed files with 131 additions and 227 deletions

View File

@@ -91,72 +91,6 @@ bool AdapterManager::isAggregatedClient(Client* client)
}
}
Client* AdapterManager::getClient(MQTTSNPacket* packet, ClientRecvTask* task)
{
char buf[128];
WirelessNodeId nodeId;
SensorNetAddress* senderAddr = _gateway->getSensorNetwork()->getSenderAddress();
Client* client = nullptr;
if ( packet->getType() == MQTTSN_ENCAPSULATED )
{
Forwarder* fwd = getForwarderList()->getForwarder(senderAddr);
if ( fwd == nullptr )
{
task->log(0, packet, 0);
WRITELOG("%s Forwarder %s is not authenticated.%s\n", ERRMSG_HEADER, senderAddr->sprint(buf), ERRMSG_FOOTER);
delete packet;
return client;
}
else
{
MQTTSNString fwdName = MQTTSNString_initializer;
fwdName.cstring = const_cast<char *>( fwd->getName() );
task->log(0, packet, &fwdName);
/* get the packet from the encapsulation message */
MQTTSNGWEncapsulatedPacket encap;
encap.desirialize(packet->getPacketData(), packet->getPacketLength());
nodeId.setId( encap.getWirelessNodeId() );
client = fwd->getClient(&nodeId);
delete packet;
packet = encap.getMQTTSNPacket();
}
}
else
{
/* Check the client belonging to QoS-1Proxy ? */
if ( _qosm1Proxy->isActive() )
{
/* get ClientId not Client which can send QoS-1 PUBLISH */
const char* clientName = _qosm1Proxy->getClientId(senderAddr);
if ( clientName )
{
if ( !packet->isQoSMinusPUBLISH() )
{
client = _qosm1Proxy->getClient();
task->log(clientName, packet);
WRITELOG("%s %s %s can send only PUBLISH with QoS-1.%s\n", ERRMSG_HEADER, clientName, senderAddr->sprint(buf), ERRMSG_FOOTER);
delete packet;
return client;
}
}
}
}
if ( client == nullptr )
{
/* get client from the ClientList of Gateway by sensorNetAddress. */
client = _gateway->getClientList()->getClient(senderAddr);
}
return client;
}
Client* AdapterManager::getClient(Client& client)
{
bool secure = client.isSecureNetwork();