mirror of
https://github.com/eclipse/paho.mqtt-sn.embedded-c.git
synced 2025-12-17 01:16:52 +01:00
Forwerders are declared by the ClientList file.
Signed-off-by: tomoaki <tomoaki@tomy-tech.com>
This commit is contained in:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user