void removeDataPathInfo(uint16_t pubSubId);
NanDataPathInformation *getDataPathInfo(uint32_t dataPathId);
NanDataPathInformation *getDataPathInfo(uint16_t pubSubId, uint32_t peerId);
+ NanDataPathInformation *getDataPathInfo(uint16_t pubSubId, const uint8_t *peerMac);
void clear();
}\
} while (0)
+bool isSameMacAddress(const uint8_t *mac1, const uint8_t *mac2);
bool isWifiInterfaceUp(const char *interfaceName);
int addRoute(const char *interfaceName, const char *ipv6Address);
int deleteRoute(const char *interfaceName, const char *ipv6Address);
#include "NanDataPathManager.h"
#include "NanDefinitions.h"
#include "NanLog.h"
+#include "NanUtils.h"
NAN_NAMESPACE_USE;
return iter->second;
}
+NanDataPathInformation *NanDataPathManager::getDataPathInfo(uint16_t pubSubId, const uint8_t *peerMac)
+{
+ for (const auto &kv : mDataPathInfoMap) {
+ if (kv.first.first != pubSubId)
+ continue;
+ NanPeer *peer = kv.second->getPeer();
+ if (peer != nullptr && isSameMacAddress(peer->getMacAddr(), peerMac)) {
+ NAN_LOGI("found! pubSubId: %u, ndpId: %d)", pubSubId, kv.second->getDataPathId());
+ return kv.second;
+ }
+ }
+ return nullptr;
+}
+
void NanDataPathManager::removeAllDataPathInfo()
{
for (const auto &kv : mDataPathInfoMap)
#include "NanPeerManager.h"
#include "NanLog.h"
+#include "NanUtils.h"
NAN_NAMESPACE_USE;
for (auto peerIterator = mPeerMap.begin(); peerIterator != mPeerMap.end(); peerIterator++)
{
if (requestorId == peerIterator->second->getRequestorId()
- && memcmp(addr, peerIterator->second->getMacAddr(), NAN_MAC_ADDR_LEN) == 0) {
+ && isSameMacAddress(addr, peerIterator->second->getMacAddr()) == 0) {
NAN_LOGI("found peer(%d)", peerIterator->first);
return peerIterator->second;
}
NAN_LOGI("Receive Event [DATA_PATH_REQUEST]");
NAN_LOGI("serviceId(%u) dataPathId(%u)", event.serviceId, event.dataPathId);
- NanPeer *peer = mPeerManager.findPeer(event.serviceId, event.addr);
NanClient *client = mClientManager.getClientWithPubSubId(event.serviceId);
- if (!peer && client) {
- NAN_LOGE("No matched peer. Send End event.");
- closeDataPathInternal(event.dataPathId, client->getClientId());
- // Don't need to emit a signal because it is going to be sent in receiveDataPathEndEvent.
- return;
- } else if (!client) {
+ if (!client) {
NAN_LOGE("No matched client. Send End event.");
closeDataPathInternal(event.dataPathId, -1);
return;
}
NanDataPathInformation *info
- = mDataPathManager.getDataPathInfo(event.serviceId, peer->getPeerId());
+ = mDataPathManager.getDataPathInfo(event.serviceId, event.addr);
if (!info) {
NAN_LOGE("No matched DataPathInfo. Send End event");
closeDataPathInternal(event.dataPathId, client->getClientId());
#include <sys/socket.h>
#include <unistd.h>
-#include "NanUtils.h"
+#include "NanDefinitions.h"
#include "NanLog.h"
+#include "NanUtils.h"
+
+bool isSameMacAddress(const uint8_t *mac1, const uint8_t *mac2)
+{
+ return memcmp(mac1, mac2, NAN_MAC_ADDR_LEN) == 0;
+}
bool isWifiInterfaceUp(const char *interfaceName)
{