//
// ccallsignlistitem.cpp
// m17ref
//
// Created by Jean-Luc Deltombe (LX3JL) on 31/01/2016.
// Copyright © 2015 Jean-Luc Deltombe (LX3JL). All rights reserved.
// Copyright © 2020,2022 Thomas A. Early N7TAE
//
// ----------------------------------------------------------------------------
// This file is part of m17ref.
//
// m17ref 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 3 of the License, or
// (at your option) any later version.
//
// m17ref 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
// with this software. If not, see .
// ----------------------------------------------------------------------------
#include
#include "Configure.h"
#include "InterlinkMapItem.h"
#include "Reflector.h"
////////////////////////////////////////////////////////////////////////////////////////
// constructor
#ifdef NO_DHT
CInterlinkMapItem::CInterlinkMapItem()
{
m_UsesDHT = false;
}
#else
CInterlinkMapItem::CInterlinkMapItem()
{
m_UsesDHT = false;
m_Updated = false;
}
#endif
#ifndef NO_DHT
CInterlinkMapItem::CInterlinkMapItem(const char *mods)
{
m_UsesDHT = true;
m_Updated = false;
m_Mods.assign(mods);
}
#endif
CInterlinkMapItem::CInterlinkMapItem(const char *addr, const char *mods, uint16_t port) : CInterlinkMapItem()
{
m_Mods.assign(mods);
m_Ip.Initialize(strchr(addr, ':') ? AF_INET6 : AF_INET, port, addr);
}
////////////////////////////////////////////////////////////////////////////////////////
// compare
bool CInterlinkMapItem::HasModuleListed(char module) const
{
return m_Mods.npos != m_Mods.find(module);
}
bool CInterlinkMapItem::HasSameIp(const CIp &ip)
{
return ip == m_Ip;
}
bool CInterlinkMapItem::CheckListedModules(const char *mods) const
{
if (mods == nullptr)
return false;
// make sure every mods character is matched in m_Mods
const auto count = m_Mods.size();
bool found[count];
for (unsigned i=0; i