2024-12-03 10:36:06 +08:00
|
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
/**
|
|
|
|
Copyright (c) 2015 - 2022 Beckhoff Automation GmbH & Co. KG
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "AdsDef.h"
|
2024-12-09 09:41:04 +08:00
|
|
|
#include <iostream>
|
2024-12-03 10:36:06 +08:00
|
|
|
#include <sstream>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2024-12-09 09:41:04 +08:00
|
|
|
namespace Beckhoff
|
|
|
|
{
|
|
|
|
namespace Ads
|
|
|
|
{
|
2024-12-03 10:36:06 +08:00
|
|
|
bool operator<(const AmsNetId& lhs, const AmsNetId& rhs)
|
|
|
|
{
|
|
|
|
for (unsigned int i = 0; i < sizeof(rhs.b); ++i) {
|
|
|
|
if (lhs.b[i] != rhs.b[i]) {
|
|
|
|
return lhs.b[i] < rhs.b[i];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-12-09 09:41:04 +08:00
|
|
|
bool operator==(const AmsNetId& lhs, const AmsNetId& rhs)
|
|
|
|
{
|
|
|
|
return 0 == memcmp(&lhs, &rhs, sizeof(lhs));
|
|
|
|
}
|
|
|
|
|
2024-12-03 10:36:06 +08:00
|
|
|
bool operator<(const AmsAddr& lhs, const AmsAddr& rhs)
|
|
|
|
{
|
|
|
|
if (memcmp(&lhs.netId, &rhs.netId, sizeof(lhs.netId))) {
|
|
|
|
return lhs.netId < rhs.netId;
|
|
|
|
}
|
|
|
|
return lhs.port < rhs.port;
|
|
|
|
}
|
|
|
|
|
2024-12-09 09:41:04 +08:00
|
|
|
bool operator==(const AmsAddr& lhs, const AmsAddr& rhs)
|
|
|
|
{
|
|
|
|
return 0 == memcmp(&lhs, &rhs, sizeof(lhs));
|
|
|
|
}
|
|
|
|
|
2024-12-03 10:36:06 +08:00
|
|
|
std::ostream& operator<<(std::ostream& os, const AmsNetId& netId)
|
|
|
|
{
|
|
|
|
return os << std::dec << (int)netId.b[0] << '.' << (int)netId.b[1] << '.' << (int)netId.b[2] << '.' <<
|
|
|
|
(int)netId.b[3] << '.' << (int)netId.b[4] << '.' << (int)netId.b[5];
|
|
|
|
}
|
|
|
|
}
|
2024-12-09 09:41:04 +08:00
|
|
|
}
|