Rename "HifiSockAddr" to "SockAddr"

This commit is contained in:
David Rowe 2021-07-06 13:23:57 +12:00
parent cdd2341880
commit 6a17143df8
52 changed files with 355 additions and 311 deletions

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 11/25/2013.
// Copyright 2013 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -82,7 +83,7 @@ AssignmentClient::AssignmentClient(Assignment::Type requestAssignmentType, QStri
_assignmentServerHostname = assignmentServerHostname;
}
_assignmentServerSocket = HifiSockAddr(_assignmentServerHostname, assignmentServerPort, true);
_assignmentServerSocket = SockAddr(_assignmentServerHostname, assignmentServerPort, true);
if (_assignmentServerSocket.isNull()) {
qCCritical(assignment_client) << "PAGE: Couldn't resolve domain server address" << _assignmentServerHostname;
}
@ -110,7 +111,7 @@ AssignmentClient::AssignmentClient(Assignment::Type requestAssignmentType, QStri
// did we get an assignment-client monitor port?
if (assignmentMonitorPort > 0) {
_assignmentClientMonitorSocket = HifiSockAddr(DEFAULT_ASSIGNMENT_CLIENT_MONITOR_HOSTNAME, assignmentMonitorPort);
_assignmentClientMonitorSocket = SockAddr(DEFAULT_ASSIGNMENT_CLIENT_MONITOR_HOSTNAME, assignmentMonitorPort);
_assignmentClientMonitorSocket.setObjectName("AssignmentClientMonitor");
qCDebug(assignment_client) << "Assignment-client monitor socket is" << _assignmentClientMonitorSocket;
@ -269,7 +270,7 @@ void AssignmentClient::handleCreateAssignmentPacket(QSharedPointer<ReceivedMessa
}
void AssignmentClient::handleStopNodePacket(QSharedPointer<ReceivedMessage> message) {
const HifiSockAddr& senderSockAddr = message->getSenderSockAddr();
const SockAddr& senderSockAddr = message->getSenderSockAddr();
if (senderSockAddr.getAddress() == QHostAddress::LocalHost ||
senderSockAddr.getAddress() == QHostAddress::LocalHostIPv6) {

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 11/25/2013.
// Copyright 2013 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -49,13 +50,13 @@ private:
QPointer<ThreadedAssignment> _currentAssignment;
bool _isAssigned { false };
QString _assignmentServerHostname;
HifiSockAddr _assignmentServerSocket;
SockAddr _assignmentServerSocket;
QTimer _requestTimer; // timer for requesting and assignment
QTimer _statsTimerACM; // timer for sending stats to assignment client monitor
QUuid _childAssignmentUUID = QUuid::createUuid();
protected:
HifiSockAddr _assignmentClientMonitorSocket;
SockAddr _assignmentClientMonitorSocket;
};
#endif // hifi_AssignmentClient_h

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 1/10/2014.
// Copyright 2014 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -331,7 +332,7 @@ void AssignmentClientMonitor::handleChildStatusPacket(QSharedPointer<ReceivedMes
auto nodeList = DependencyManager::get<NodeList>();
SharedNodePointer matchingNode = nodeList->nodeWithUUID(senderID);
const HifiSockAddr& senderSockAddr = message->getSenderSockAddr();
const SockAddr& senderSockAddr = message->getSenderSockAddr();
AssignmentClientChildData* childData = nullptr;

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 9/5/13.
// Copyright 2013 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -113,7 +114,7 @@ AvatarMixer::AvatarMixer(ReceivedMessage& message) :
});
}
SharedNodePointer addOrUpdateReplicatedNode(const QUuid& nodeID, const HifiSockAddr& senderSockAddr) {
SharedNodePointer addOrUpdateReplicatedNode(const QUuid& nodeID, const SockAddr& senderSockAddr) {
auto replicatedNode = DependencyManager::get<NodeList>()->addOrUpdateNode(nodeID, NodeType::Agent,
senderSockAddr,
senderSockAddr,
@ -976,7 +977,7 @@ void AvatarMixer::domainSettingsRequestComplete() {
start();
}
void AvatarMixer::handlePacketVersionMismatch(PacketType type, const HifiSockAddr& senderSockAddr, const QUuid& senderUUID) {
void AvatarMixer::handlePacketVersionMismatch(PacketType type, const SockAddr& senderSockAddr, const QUuid& senderUUID) {
// if this client is using packet versions we don't expect.
if ((type == PacketTypeEnum::Value::AvatarIdentity || type == PacketTypeEnum::Value::AvatarData) && !senderUUID.isNull()) {
// Echo an empty AvatarData packet back to that client.

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 9/5/13.
// Copyright 2013 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// The avatar mixer receives head, hand and positional data from all connected
// nodes, and broadcasts that data back to them, every BROADCAST_INTERVAL ms.
@ -63,7 +64,7 @@ private slots:
void handleReplicatedPacket(QSharedPointer<ReceivedMessage> message);
void handleReplicatedBulkAvatarPacket(QSharedPointer<ReceivedMessage> message);
void domainSettingsRequestComplete();
void handlePacketVersionMismatch(PacketType type, const HifiSockAddr& senderSockAddr, const QUuid& senderUUID);
void handlePacketVersionMismatch(PacketType type, const SockAddr& senderSockAddr, const QUuid& senderUUID);
void handleOctreePacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer senderNode);
void start();

View file

@ -357,7 +357,7 @@ void DomainGatekeeper::updateNodePermissions() {
} else {
// at this point we don't have a sending socket for packets from this node - assume it is the active socket
// or the public socket if we haven't activated a socket for the node yet
HifiSockAddr connectingAddr = node->getActiveSocket() ? *node->getActiveSocket() : node->getPublicSocket();
SockAddr connectingAddr = node->getActiveSocket() ? *node->getActiveSocket() : node->getPublicSocket();
QString hardwareAddress;
QUuid machineFingerprint;
@ -651,7 +651,7 @@ SharedNodePointer DomainGatekeeper::processAgentConnectRequest(const NodeConnect
}
SharedNodePointer DomainGatekeeper::addVerifiedNodeFromConnectRequest(const NodeConnectionData& nodeConnection) {
HifiSockAddr discoveredSocket = nodeConnection.senderSockAddr;
SockAddr discoveredSocket = nodeConnection.senderSockAddr;
SharedNetworkPeer connectedPeer = _icePeers.value(nodeConnection.connectUUID);
if (connectedPeer && connectedPeer->getActiveSocket()) {
@ -690,7 +690,7 @@ void DomainGatekeeper::cleanupICEPeerForNode(const QUuid& nodeID) {
bool DomainGatekeeper::verifyUserSignature(const QString& username,
const QByteArray& usernameSignature,
const HifiSockAddr& senderSockAddr) {
const SockAddr& senderSockAddr) {
// it's possible this user can be allowed to connect, but we need to check their username signature
auto lowerUsername = username.toLower();
KeyFlagPair publicKeyPair = _userPublicKeys.value(lowerUsername);
@ -773,7 +773,7 @@ bool DomainGatekeeper::needToVerifyDomainUserIdentity(const QString& username, c
}
bool DomainGatekeeper::verifyDomainUserIdentity(const QString& username, const QString& accessToken,
const QString& refreshToken, const HifiSockAddr& senderSockAddr) {
const QString& refreshToken, const SockAddr& senderSockAddr) {
if (_verifiedDomainUserIdentities.contains(username)
&& _verifiedDomainUserIdentities.value(username) == QPair<QString, QString>(accessToken, refreshToken)) {
return true;
@ -871,7 +871,7 @@ void DomainGatekeeper::publicKeyJSONErrorCallback(QNetworkReply* requestReply) {
_inFlightPublicKeyRequests.remove(username);
}
void DomainGatekeeper::sendProtocolMismatchConnectionDenial(const HifiSockAddr& senderSockAddr) {
void DomainGatekeeper::sendProtocolMismatchConnectionDenial(const SockAddr& senderSockAddr) {
QString protocolVersionError = "Protocol version mismatch - Domain version: " + QCoreApplication::applicationVersion();
qDebug() << "Protocol Version mismatch - denying connection.";
@ -880,7 +880,7 @@ void DomainGatekeeper::sendProtocolMismatchConnectionDenial(const HifiSockAddr&
DomainHandler::ConnectionRefusedReason::ProtocolMismatch);
}
void DomainGatekeeper::sendConnectionDeniedPacket(const QString& reason, const HifiSockAddr& senderSockAddr,
void DomainGatekeeper::sendConnectionDeniedPacket(const QString& reason, const SockAddr& senderSockAddr,
DomainHandler::ConnectionRefusedReason reasonCode,
QString extraInfo) {
// this is an agent and we've decided we won't let them connect - send them a packet to deny connection
@ -910,7 +910,7 @@ void DomainGatekeeper::sendConnectionDeniedPacket(const QString& reason, const H
DependencyManager::get<LimitedNodeList>()->sendPacket(std::move(connectionDeniedPacket), senderSockAddr);
}
void DomainGatekeeper::sendConnectionTokenPacket(const QString& username, const HifiSockAddr& senderSockAddr) {
void DomainGatekeeper::sendConnectionTokenPacket(const QString& username, const SockAddr& senderSockAddr) {
// get the existing connection token or create a new one
QUuid& connectionToken = _connectionTokenHash[username.toLower()];

View file

@ -47,7 +47,7 @@ public:
Node::LocalID findOrCreateLocalID(const QUuid& uuid);
static void sendProtocolMismatchConnectionDenial(const HifiSockAddr& senderSockAddr);
static void sendProtocolMismatchConnectionDenial(const SockAddr& senderSockAddr);
public slots:
void processConnectRequestPacket(QSharedPointer<ReceivedMessage> message);
void processICEPingPacket(QSharedPointer<ReceivedMessage> message);
@ -90,19 +90,19 @@ private:
SharedNodePointer addVerifiedNodeFromConnectRequest(const NodeConnectionData& nodeConnection);
bool verifyUserSignature(const QString& username, const QByteArray& usernameSignature,
const HifiSockAddr& senderSockAddr);
const SockAddr& senderSockAddr);
bool needToVerifyDomainUserIdentity(const QString& username, const QString& accessToken, const QString& refreshToken);
bool verifyDomainUserIdentity(const QString& username, const QString& accessToken, const QString& refreshToken,
const HifiSockAddr& senderSockAddr);
const SockAddr& senderSockAddr);
bool isWithinMaxCapacity();
bool shouldAllowConnectionFromNode(const QString& username, const QByteArray& usernameSignature,
const HifiSockAddr& senderSockAddr);
const SockAddr& senderSockAddr);
void sendConnectionTokenPacket(const QString& username, const HifiSockAddr& senderSockAddr);
static void sendConnectionDeniedPacket(const QString& reason, const HifiSockAddr& senderSockAddr,
void sendConnectionTokenPacket(const QString& username, const SockAddr& senderSockAddr);
static void sendConnectionDeniedPacket(const QString& reason, const SockAddr& senderSockAddr,
DomainHandler::ConnectionRefusedReason reasonCode = DomainHandler::ConnectionRefusedReason::Unknown,
QString extraInfo = QString());

View file

@ -777,7 +777,7 @@ void DomainServer::setupNodeListAndAssignments() {
connect(nodeList.data(), &LimitedNodeList::nodeAdded, this, &DomainServer::nodeAdded);
connect(nodeList.data(), &LimitedNodeList::nodeKilled, this, &DomainServer::nodeKilled);
connect(nodeList.data(), &LimitedNodeList::localSockAddrChanged, this,
[this](const HifiSockAddr& localSockAddr) {
[this](const SockAddr& localSockAddr) {
DependencyManager::get<LimitedNodeList>()->putLocalPortIntoSharedMemory(DOMAIN_SERVER_LOCAL_PORT_SMEM_KEY, this, localSockAddr.getPort());
});
@ -1225,7 +1225,7 @@ void DomainServer::handleConnectedNode(SharedNodePointer newNode, quint64 reques
broadcastNewNode(newNode);
}
void DomainServer::sendDomainListToNode(const SharedNodePointer& node, quint64 requestPacketReceiveTime, const HifiSockAddr &senderSockAddr, bool newConnection) {
void DomainServer::sendDomainListToNode(const SharedNodePointer& node, quint64 requestPacketReceiveTime, const SockAddr &senderSockAddr, bool newConnection) {
const int NUM_DOMAIN_LIST_EXTENDED_HEADER_BYTES = NUM_BYTES_RFC4122_UUID + NLPacket::NUM_BYTES_LOCALID +
NUM_BYTES_RFC4122_UUID + NLPacket::NUM_BYTES_LOCALID + 4;
@ -1501,7 +1501,7 @@ void DomainServer::transactionJSONCallback(const QJsonObject& data) {
}
}
QJsonObject jsonForDomainSocketUpdate(const HifiSockAddr& socket) {
QJsonObject jsonForDomainSocketUpdate(const SockAddr& socket) {
const QString SOCKET_NETWORK_ADDRESS_KEY = "network_address";
const QString SOCKET_PORT_KEY = "port";
@ -1512,7 +1512,7 @@ QJsonObject jsonForDomainSocketUpdate(const HifiSockAddr& socket) {
return socketObject;
}
void DomainServer::performIPAddressPortUpdate(const HifiSockAddr& newPublicSockAddr) {
void DomainServer::performIPAddressPortUpdate(const SockAddr& newPublicSockAddr) {
const QString& DOMAIN_SERVER_SETTINGS_KEY = "domain_server";
const QString& publicSocketAddress = newPublicSockAddr.getAddress().toString();
const int publicSocketPort = newPublicSockAddr.getPort();
@ -1770,7 +1770,7 @@ void DomainServer::sendHeartbeatToIceServer() {
QDataStream heartbeatStream(_iceServerHeartbeatPacket.get());
QUuid senderUUID;
HifiSockAddr publicSocket, localSocket;
SockAddr publicSocket, localSocket;
heartbeatStream >> senderUUID >> publicSocket >> localSocket;
if (senderUUID != limitedNodeList->getSessionUUID()
@ -1928,7 +1928,7 @@ void DomainServer::processNodeJSONStatsPacket(QSharedPointer<ReceivedMessage> pa
}
}
QJsonObject DomainServer::jsonForSocket(const HifiSockAddr& socket) {
QJsonObject DomainServer::jsonForSocket(const SockAddr& socket) {
QJsonObject socketJSON;
socketJSON["ip"] = socket.getAddress().toString();
@ -3017,7 +3017,7 @@ static const QString BROADCASTING_SETTINGS_KEY = "broadcasting";
struct ReplicationServerInfo {
NodeType_t nodeType;
HifiSockAddr sockAddr;
SockAddr sockAddr;
};
ReplicationServerInfo serverInformationFromSettings(QVariantMap serverMap, ReplicationServerDirection direction) {
@ -3038,7 +3038,7 @@ ReplicationServerInfo serverInformationFromSettings(QVariantMap serverMap, Repli
serverInfo.nodeType = NodeType::downstreamType(nodeType);
}
// read the address and port and construct a HifiSockAddr from them
// read the address and port and construct a SockAddr from them
serverInfo.sockAddr = {
serverMap[REPLICATION_SERVER_ADDRESS].toString(),
(quint16) serverMap[REPLICATION_SERVER_PORT].toString().toInt()
@ -3047,7 +3047,7 @@ ReplicationServerInfo serverInformationFromSettings(QVariantMap serverMap, Repli
return serverInfo;
}
return { NodeType::Unassigned, HifiSockAddr() };
return { NodeType::Unassigned, SockAddr() };
}
void DomainServer::updateReplicationNodes(ReplicationServerDirection direction) {
@ -3056,7 +3056,7 @@ void DomainServer::updateReplicationNodes(ReplicationServerDirection direction)
if (broadcastSettingsVariant.isValid()) {
auto nodeList = DependencyManager::get<LimitedNodeList>();
std::vector<HifiSockAddr> replicationNodesInSettings;
std::vector<SockAddr> replicationNodesInSettings;
auto replicationSettings = broadcastSettingsVariant.toMap();
@ -3066,7 +3066,7 @@ void DomainServer::updateReplicationNodes(ReplicationServerDirection direction)
if (replicationSettings.contains(serversKey)) {
auto serversSettings = replicationSettings.value(serversKey).toList();
std::vector<HifiSockAddr> knownReplicationNodes;
std::vector<SockAddr> knownReplicationNodes;
nodeList->eachNode([direction, &knownReplicationNodes](const SharedNodePointer& otherNode) {
if ((direction == Upstream && NodeType::isUpstream(otherNode->getType()))
|| (direction == Downstream && NodeType::isDownstream(otherNode->getType()))) {
@ -3620,7 +3620,7 @@ void DomainServer::randomizeICEServerAddress(bool shouldTriggerHostLookup) {
indexToTry = distribution(generator);
}
_iceServerSocket = HifiSockAddr { candidateICEAddresses[indexToTry], ICE_SERVER_DEFAULT_PORT };
_iceServerSocket = SockAddr { candidateICEAddresses[indexToTry], ICE_SERVER_DEFAULT_PORT };
qCInfo(domain_server_ice) << "Set candidate ice-server socket to" << _iceServerSocket;
// clear our number of hearbeat denials, this should be re-set on ice-server change

View file

@ -113,7 +113,7 @@ private slots:
void setupPendingAssignmentCredits();
void sendPendingTransactionsToServer();
void performIPAddressPortUpdate(const HifiSockAddr& newPublicSockAddr);
void performIPAddressPortUpdate(const SockAddr& newPublicSockAddr);
void sendHeartbeatToMetaverse() { sendHeartbeatToMetaverse(QString(), int()); }
void sendHeartbeatToIceServer();
void nodePingMonitor();
@ -186,7 +186,7 @@ private:
void handleKillNode(SharedNodePointer nodeToKill);
void broadcastNodeDisconnect(const SharedNodePointer& disconnnectedNode);
void sendDomainListToNode(const SharedNodePointer& node, quint64 requestPacketReceiveTime, const HifiSockAddr& senderSockAddr, bool newConnection);
void sendDomainListToNode(const SharedNodePointer& node, quint64 requestPacketReceiveTime, const SockAddr& senderSockAddr, bool newConnection);
bool isInInterestSet(const SharedNodePointer& nodeA, const SharedNodePointer& nodeB);
@ -212,7 +212,7 @@ private:
QNetworkReply* profileRequestGivenTokenReply(QNetworkReply* tokenReply);
Headers setupCookieHeadersFromProfileReply(QNetworkReply* profileReply);
QJsonObject jsonForSocket(const HifiSockAddr& socket);
QJsonObject jsonForSocket(const SockAddr& socket);
QJsonObject jsonObjectForNode(const SharedNodePointer& node);
bool shouldReplicateNode(const Node& node);
@ -270,7 +270,7 @@ private:
DomainServerSettingsManager _settingsManager;
HifiSockAddr _iceServerSocket;
SockAddr _iceServerSocket;
std::unique_ptr<NLPacket> _iceServerHeartbeatPacket;
// These will be parented to this, they are not dangling

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2/6/2014.
// Copyright 2014 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -17,7 +18,7 @@
#include <QtCore/QUuid>
#include <QtCore/QJsonObject>
#include <HifiSockAddr.h>
#include <SockAddr.h>
#include <NLPacket.h>
#include <NodeData.h>
#include <NodeType.h>
@ -41,8 +42,8 @@ public:
QElapsedTimer& getPaymentIntervalTimer() { return _paymentIntervalTimer; }
void setSendingSockAddr(const HifiSockAddr& sendingSockAddr) { _sendingSockAddr = sendingSockAddr; }
const HifiSockAddr& getSendingSockAddr() { return _sendingSockAddr; }
void setSendingSockAddr(const SockAddr& sendingSockAddr) { _sendingSockAddr = sendingSockAddr; }
const SockAddr& getSendingSockAddr() { return _sendingSockAddr; }
void setIsAuthenticated(bool isAuthenticated) { _isAuthenticated = isAuthenticated; }
bool isAuthenticated() const { return _isAuthenticated; }
@ -90,7 +91,7 @@ private:
QJsonObject _statsJSONObject;
static StringPairHash _overrideHash;
HifiSockAddr _sendingSockAddr;
SockAddr _sendingSockAddr;
bool _isAuthenticated = true;
NodeSet _nodeInterestSet;
QString _nodeVersion;

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2015-08-24.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -13,7 +14,7 @@
#include <QtCore/QDataStream>
NodeConnectionData NodeConnectionData::fromDataStream(QDataStream& dataStream, const HifiSockAddr& senderSockAddr,
NodeConnectionData NodeConnectionData::fromDataStream(QDataStream& dataStream, const SockAddr& senderSockAddr,
bool isConnectRequest) {
NodeConnectionData newHeader;

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2015-08-24.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -18,15 +19,15 @@
class NodeConnectionData {
public:
static NodeConnectionData fromDataStream(QDataStream& dataStream, const HifiSockAddr& senderSockAddr,
static NodeConnectionData fromDataStream(QDataStream& dataStream, const SockAddr& senderSockAddr,
bool isConnectRequest = true);
QUuid connectUUID;
quint64 lastPingTimestamp{ 0 }; // client-side send time of last connect/domain list request
NodeType_t nodeType;
HifiSockAddr publicSockAddr;
HifiSockAddr localSockAddr;
HifiSockAddr senderSockAddr;
SockAddr publicSockAddr;
SockAddr localSockAddr;
SockAddr senderSockAddr;
QList<NodeType_t> interestList;
QString placeName;
QString hardwareAddress;

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2014-10-01.
// Copyright 2014 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -97,7 +98,7 @@ void IceServer::processPacket(std::unique_ptr<udt::Packet> packet) {
heartbeatStream >> senderUUID;
// pull the public and private sock addrs for this peer
HifiSockAddr publicSocket, localSocket;
SockAddr publicSocket, localSocket;
heartbeatStream >> publicSocket >> localSocket;
// check if this node also included a UUID that they would like to connect to
@ -129,7 +130,7 @@ SharedNetworkPeer IceServer::addOrUpdateHeartbeatingPeer(NLPacket& packet) {
// pull the UUID, public and private sock addrs for this peer
QUuid senderUUID;
HifiSockAddr publicSocket, localSocket;
SockAddr publicSocket, localSocket;
QByteArray signature;
QDataStream heartbeatStream(&packet);
@ -288,7 +289,7 @@ void IceServer::publicKeyReplyFinished(QNetworkReply* reply) {
reply->deleteLater();
}
void IceServer::sendPeerInformationPacket(const NetworkPeer& peer, const HifiSockAddr* destinationSockAddr) {
void IceServer::sendPeerInformationPacket(const NetworkPeer& peer, const SockAddr* destinationSockAddr) {
auto peerPacket = NLPacket::create(PacketType::ICEServerPeerInformation);
// get the byte array for this peer

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2014-10-01.
// Copyright 2014 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -40,7 +41,7 @@ private:
void processPacket(std::unique_ptr<udt::Packet> packet);
SharedNetworkPeer addOrUpdateHeartbeatingPeer(NLPacket& incomingPacket);
void sendPeerInformationPacket(const NetworkPeer& peer, const HifiSockAddr* destinationSockAddr);
void sendPeerInformationPacket(const NetworkPeer& peer, const SockAddr* destinationSockAddr);
bool isVerifiedHeartbeat(const QUuid& domainID, const QByteArray& plaintext, const QByteArray& signature);
void requestDomainPublicKey(const QUuid& domainID);

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 1/22/13.
// Copyright 2013 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -33,7 +34,7 @@
#include <shared/WebRTC.h>
#include <DependencyManager.h>
#include <HifiSockAddr.h>
#include <SockAddr.h>
#include <NLPacket.h>
#include <MixedProcessedAudioStream.h>
#include <RingBufferHistory.h>

View file

@ -26,7 +26,7 @@
#include "AddressManager.h"
#include "Assignment.h"
#include "DomainAccountManager.h"
#include "HifiSockAddr.h"
#include "SockAddr.h"
#include "NodeList.h"
#include "udt/Packet.h"
#include "udt/PacketHeaders.h"
@ -37,7 +37,7 @@
DomainHandler::DomainHandler(QObject* parent) :
QObject(parent),
_sockAddr(HifiSockAddr(QHostAddress::Null, DEFAULT_DOMAIN_SERVER_PORT)),
_sockAddr(SockAddr(QHostAddress::Null, DEFAULT_DOMAIN_SERVER_PORT)),
_icePeer(this),
_settingsTimer(this),
_apiRefreshTimer(this)
@ -133,7 +133,7 @@ void DomainHandler::hardReset(QString reason) {
qCDebug(networking) << "Hard reset in NodeList DomainHandler.";
_pendingDomainID = QUuid();
_iceServerSockAddr = HifiSockAddr();
_iceServerSockAddr = SockAddr();
_sockAddr.clear();
_domainURL = QUrl();
@ -170,7 +170,7 @@ void DomainHandler::setErrorDomainURL(const QUrl& url) {
return;
}
void DomainHandler::setSockAddr(const HifiSockAddr& sockAddr, const QString& hostname) {
void DomainHandler::setSockAddr(const SockAddr& sockAddr, const QString& hostname) {
if (_sockAddr != sockAddr) {
// we should reset on a sockAddr change
hardReset("Changing domain sockAddr");
@ -280,9 +280,9 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
_pendingDomainID = id;
HifiSockAddr* replaceableSockAddr = &_iceServerSockAddr;
replaceableSockAddr->~HifiSockAddr();
replaceableSockAddr = new (replaceableSockAddr) HifiSockAddr(iceServerHostname, ICE_SERVER_DEFAULT_PORT);
SockAddr* replaceableSockAddr = &_iceServerSockAddr;
replaceableSockAddr->~SockAddr();
replaceableSockAddr = new (replaceableSockAddr) SockAddr(iceServerHostname, ICE_SERVER_DEFAULT_PORT);
_iceServerSockAddr.setObjectName("IceServer");
auto nodeList = DependencyManager::get<NodeList>();
@ -291,7 +291,7 @@ void DomainHandler::setIceServerHostnameAndID(const QString& iceServerHostname,
if (_iceServerSockAddr.getAddress().isNull()) {
// connect to lookup completed for ice-server socket so we can request a heartbeat once hostname is looked up
connect(&_iceServerSockAddr, &HifiSockAddr::lookupCompleted, this, &DomainHandler::completedIceServerHostnameLookup);
connect(&_iceServerSockAddr, &SockAddr::lookupCompleted, this, &DomainHandler::completedIceServerHostnameLookup);
} else {
completedIceServerHostnameLookup();
}
@ -458,7 +458,7 @@ void DomainHandler::processSettingsPacketList(QSharedPointer<ReceivedMessage> pa
}
void DomainHandler::processICEPingReplyPacket(QSharedPointer<ReceivedMessage> message) {
const HifiSockAddr& senderSockAddr = message->getSenderSockAddr();
const SockAddr& senderSockAddr = message->getSenderSockAddr();
qCDebug(networking_ice) << "Received reply from domain-server on" << senderSockAddr;
if (getIP().isNull()) {

View file

@ -25,7 +25,7 @@
#include <shared/ReadWriteLockable.h>
#include <SettingHandle.h>
#include "HifiSockAddr.h"
#include "SockAddr.h"
#include "NetworkPeer.h"
#include "NLPacket.h"
#include "NLPacketList.h"
@ -109,8 +109,8 @@ public:
const QHostAddress& getIP() const { return _sockAddr.getAddress(); }
void setIPToLocalhost() { _sockAddr.setAddress(QHostAddress(QHostAddress::LocalHost)); }
const HifiSockAddr& getSockAddr() const { return _sockAddr; }
void setSockAddr(const HifiSockAddr& sockAddr, const QString& hostname);
const SockAddr& getSockAddr() const { return _sockAddr; }
void setSockAddr(const SockAddr& sockAddr, const QString& hostname);
unsigned short getPort() const { return _sockAddr.getPort(); }
void setPort(quint16 port) { _sockAddr.setPort(port); }
@ -126,7 +126,7 @@ public:
const QUuid& getICEClientID() const { return _iceClientID; }
bool requiresICE() const { return !_iceServerSockAddr.isNull(); }
const HifiSockAddr& getICEServerSockAddr() const { return _iceServerSockAddr; }
const SockAddr& getICEServerSockAddr() const { return _iceServerSockAddr; }
NetworkPeer& getICEPeer() { return _icePeer; }
void activateICELocalSocket();
void activateICEPublicSocket();
@ -288,12 +288,12 @@ private:
Node::LocalID _localID;
QUrl _domainURL;
QUrl _errorDomainURL;
HifiSockAddr _sockAddr;
SockAddr _sockAddr;
QUuid _assignmentUUID;
QUuid _connectionToken;
QUuid _pendingDomainID; // ID of domain being connected to, via ICE or direct connection
QUuid _iceClientID;
HifiSockAddr _iceServerSockAddr;
SockAddr _iceServerSockAddr;
NetworkPeer _icePeer;
bool _isConnected { false };
bool _haveAskedConnectWithoutAvatarEntities { false };

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2/15/13.
// Copyright 2013 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -33,7 +34,7 @@
#include "AccountManager.h"
#include "AssetClient.h"
#include "Assignment.h"
#include "HifiSockAddr.h"
#include "SockAddr.h"
#include "NetworkLogging.h"
#include "udt/Packet.h"
#include "HMACAuth.h"
@ -103,7 +104,7 @@ LimitedNodeList::LimitedNodeList(int socketListenPort, int dtlsListenPort) :
_nodeSocket.setMessageHandler([this](std::unique_ptr<udt::Packet> packet) {
_packetReceiver->handleVerifiedMessagePacket(std::move(packet));
});
_nodeSocket.setMessageFailureHandler([this](HifiSockAddr from,
_nodeSocket.setMessageFailureHandler([this](SockAddr from,
udt::Packet::MessageNumber messageNumber) {
_packetReceiver->handleMessageFailure(from, messageNumber);
});
@ -120,7 +121,7 @@ LimitedNodeList::LimitedNodeList(int socketListenPort, int dtlsListenPort) :
if (_stunSockAddr.getAddress().isNull()) {
// we don't know the stun server socket yet, add it to unfiltered once known
connect(&_stunSockAddr, &HifiSockAddr::lookupCompleted, this, &LimitedNodeList::addSTUNHandlerToUnfiltered);
connect(&_stunSockAddr, &SockAddr::lookupCompleted, this, &LimitedNodeList::addSTUNHandlerToUnfiltered);
} else {
// we know the stun server socket, add it to unfiltered now
addSTUNHandlerToUnfiltered();
@ -248,11 +249,11 @@ bool LimitedNodeList::packetVersionMatch(const udt::Packet& packet) {
if (headerVersion != versionForPacketType(headerType)) {
static QMultiHash<QUuid, PacketType> sourcedVersionDebugSuppressMap;
static QMultiHash<HifiSockAddr, PacketType> versionDebugSuppressMap;
static QMultiHash<SockAddr, PacketType> versionDebugSuppressMap;
bool hasBeenOutput = false;
QString senderString;
const HifiSockAddr& senderSockAddr = packet.getSenderSockAddr();
const SockAddr& senderSockAddr = packet.getSenderSockAddr();
QUuid sourceID;
if (PacketTypeEnum::getNonSourcedPackets().contains(headerType)) {
@ -413,7 +414,7 @@ qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const Node&
return sendUnreliablePacket(packet, *destinationNode.getActiveSocket(), destinationNode.getAuthenticateHash());
}
qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr,
qint64 LimitedNodeList::sendUnreliablePacket(const NLPacket& packet, const SockAddr& sockAddr,
HMACAuth* hmacAuth) {
Q_ASSERT(!packet.isPartOfMessage());
Q_ASSERT_X(!packet.isReliable(), "LimitedNodeList::sendUnreliablePacket",
@ -446,7 +447,7 @@ qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const Node&
}
}
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const HifiSockAddr& sockAddr,
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const SockAddr& sockAddr,
HMACAuth* hmacAuth) {
Q_ASSERT(!packet->isPartOfMessage());
if (packet->isReliable()) {
@ -497,7 +498,7 @@ qint64 LimitedNodeList::sendUnreliableUnorderedPacketList(NLPacketList& packetLi
}
}
qint64 LimitedNodeList::sendUnreliableUnorderedPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr,
qint64 LimitedNodeList::sendUnreliableUnorderedPacketList(NLPacketList& packetList, const SockAddr& sockAddr,
HMACAuth* hmacAuth) {
qint64 bytesSent = 0;
@ -511,7 +512,7 @@ qint64 LimitedNodeList::sendUnreliableUnorderedPacketList(NLPacketList& packetLi
return bytesSent;
}
qint64 LimitedNodeList::sendPacketList(std::unique_ptr<NLPacketList> packetList, const HifiSockAddr& sockAddr) {
qint64 LimitedNodeList::sendPacketList(std::unique_ptr<NLPacketList> packetList, const SockAddr& sockAddr) {
// close the last packet in the list
packetList->closeCurrentPacket();
@ -543,7 +544,7 @@ qint64 LimitedNodeList::sendPacketList(std::unique_ptr<NLPacketList> packetList,
}
qint64 LimitedNodeList::sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode,
const HifiSockAddr& overridenSockAddr) {
const SockAddr& overridenSockAddr) {
if (overridenSockAddr.isNull() && !destinationNode.getActiveSocket()) {
qCDebug(networking) << "LimitedNodeList::sendPacket called without active socket for node"
<< destinationNode.getUUID() << ". Not sending.";
@ -675,7 +676,7 @@ void LimitedNodeList::handleNodeKill(const SharedNodePointer& node, ConnectionID
}
SharedNodePointer LimitedNodeList::addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
const SockAddr& publicSocket, const SockAddr& localSocket,
Node::LocalID localID, bool isReplicated, bool isUpstream,
const QUuid& connectionSecret, const NodePermissions& permissions) {
auto matchingNode = nodeWithUUID(uuid);
@ -1105,7 +1106,7 @@ void LimitedNodeList::processSTUNResponse(std::unique_ptr<udt::BasePacket> packe
_publicSockAddr.getAddress().toString().toLocal8Bit().constData(),
_publicSockAddr.getPort());
_publicSockAddr = HifiSockAddr(newPublicAddress, newPublicPort);
_publicSockAddr = SockAddr(newPublicAddress, newPublicPort);
if (!_hasCompletedInitialSTUN) {
// if we're here we have definitely completed our initial STUN sequence
@ -1133,10 +1134,10 @@ void LimitedNodeList::startSTUNPublicSocketUpdate() {
if (_stunSockAddr.getAddress().isNull()) {
// if we fail to lookup the socket then timeout the STUN address lookup
connect(&_stunSockAddr, &HifiSockAddr::lookupFailed, this, &LimitedNodeList::possiblyTimeoutSTUNAddressLookup);
connect(&_stunSockAddr, &SockAddr::lookupFailed, this, &LimitedNodeList::possiblyTimeoutSTUNAddressLookup);
// immediately send a STUN request once we know the socket
connect(&_stunSockAddr, &HifiSockAddr::lookupCompleted, this, &LimitedNodeList::sendSTUNRequest);
connect(&_stunSockAddr, &SockAddr::lookupCompleted, this, &LimitedNodeList::sendSTUNRequest);
// start the initial STUN timer once we know the socket
connect(&_stunSockAddr, SIGNAL(lookupCompleted()), _initialSTUNTimer, SLOT(start()));
@ -1186,7 +1187,7 @@ void LimitedNodeList::stopInitialSTUNUpdate(bool success) {
qCDebug(networking) << "LimitedNodeList public socket will be set with local port and null QHostAddress.";
// reset the public address and port to a null address
_publicSockAddr = HifiSockAddr(QHostAddress(), _nodeSocket.localPort());
_publicSockAddr = SockAddr(QHostAddress(), _nodeSocket.localPort());
// we have changed the publicSockAddr, so emit our signal
emit publicSockAddrChanged(_publicSockAddr);
@ -1213,7 +1214,7 @@ void LimitedNodeList::stopInitialSTUNUpdate(bool success) {
void LimitedNodeList::updateLocalSocket() {
// when update is called, if the local socket is empty then start with the guessed local socket
if (_localSockAddr.isNull()) {
setLocalSocket(HifiSockAddr { getGuessedLocalAddress(), _nodeSocket.localPort() });
setLocalSocket(SockAddr { getGuessedLocalAddress(), _nodeSocket.localPort() });
}
// attempt to use Google's DNS to confirm that local IP
@ -1237,7 +1238,7 @@ void LimitedNodeList::connectedForLocalSocketTest() {
auto localHostAddress = localIPTestSocket->localAddress();
if (localHostAddress.protocol() == QAbstractSocket::IPv4Protocol) {
setLocalSocket(HifiSockAddr { localHostAddress, _nodeSocket.localPort() });
setLocalSocket(SockAddr { localHostAddress, _nodeSocket.localPort() });
_hasTCPCheckedLocalSocket = true;
}
@ -1253,7 +1254,7 @@ void LimitedNodeList::errorTestingLocalSocket() {
// error connecting to the test socket - if we've never set our local socket using this test socket
// then use our possibly updated guessed local address as fallback
if (!_hasTCPCheckedLocalSocket) {
setLocalSocket(HifiSockAddr { getGuessedLocalAddress(), _nodeSocket.localPort() });
setLocalSocket(SockAddr { getGuessedLocalAddress(), _nodeSocket.localPort() });
qCCritical(networking) << "PAGE: Can't connect to Google DNS service via TCP, falling back to guessed local address"
<< getLocalSockAddr();
}
@ -1262,7 +1263,7 @@ void LimitedNodeList::errorTestingLocalSocket() {
}
}
void LimitedNodeList::setLocalSocket(const HifiSockAddr& sockAddr) {
void LimitedNodeList::setLocalSocket(const SockAddr& sockAddr) {
if (sockAddr.getAddress() != _localSockAddr.getAddress()) {
if (_localSockAddr.isNull()) {
@ -1283,12 +1284,12 @@ void LimitedNodeList::setLocalSocket(const HifiSockAddr& sockAddr) {
}
}
void LimitedNodeList::sendPeerQueryToIceServer(const HifiSockAddr& iceServerSockAddr, const QUuid& clientID,
void LimitedNodeList::sendPeerQueryToIceServer(const SockAddr& iceServerSockAddr, const QUuid& clientID,
const QUuid& peerID) {
sendPacketToIceServer(PacketType::ICEServerQuery, iceServerSockAddr, clientID, peerID);
}
SharedNodePointer LimitedNodeList::findNodeWithAddr(const HifiSockAddr& addr) {
SharedNodePointer LimitedNodeList::findNodeWithAddr(const SockAddr& addr) {
QReadLocker locker(&_nodeMutex);
auto it = std::find_if(std::begin(_nodeHash), std::end(_nodeHash), [&addr](const UUIDNodePair& pair) {
return pair.second->getPublicSocket() == addr
@ -1298,7 +1299,7 @@ SharedNodePointer LimitedNodeList::findNodeWithAddr(const HifiSockAddr& addr) {
return (it != std::end(_nodeHash)) ? it->second : SharedNodePointer();
}
bool LimitedNodeList::sockAddrBelongsToNode(const HifiSockAddr& sockAddr) {
bool LimitedNodeList::sockAddrBelongsToNode(const SockAddr& sockAddr) {
QReadLocker locker(&_nodeMutex);
auto it = std::find_if(std::begin(_nodeHash), std::end(_nodeHash), [&sockAddr](const UUIDNodePair& pair) {
return pair.second->getPublicSocket() == sockAddr
@ -1308,7 +1309,7 @@ bool LimitedNodeList::sockAddrBelongsToNode(const HifiSockAddr& sockAddr) {
return it != std::end(_nodeHash);
}
void LimitedNodeList::sendPacketToIceServer(PacketType packetType, const HifiSockAddr& iceServerSockAddr,
void LimitedNodeList::sendPacketToIceServer(PacketType packetType, const SockAddr& iceServerSockAddr,
const QUuid& clientID, const QUuid& peerID) {
auto icePacket = NLPacket::create(packetType);
@ -1400,7 +1401,7 @@ void LimitedNodeList::flagTimeForConnectionStep(ConnectionStep connectionStep, q
}
}
void LimitedNodeList::clientConnectionToSockAddrReset(const HifiSockAddr& sockAddr) {
void LimitedNodeList::clientConnectionToSockAddrReset(const SockAddr& sockAddr) {
// for certain reliable channels higher level classes may need to know if the udt::Connection has been reset
auto matchingNode = findNodeWithAddr(sockAddr);

View file

@ -145,26 +145,26 @@ public:
virtual bool isDomainServer() const { return true; }
virtual QUuid getDomainUUID() const { assert(false); return QUuid(); }
virtual Node::LocalID getDomainLocalID() const { assert(false); return Node::NULL_LOCAL_ID; }
virtual HifiSockAddr getDomainSockAddr() const { assert(false); return HifiSockAddr(); }
virtual SockAddr getDomainSockAddr() const { assert(false); return SockAddr(); }
// use sendUnreliablePacket to send an unreliable packet (that you do not need to move)
// either to a node (via its active socket) or to a manual sockaddr
qint64 sendUnreliablePacket(const NLPacket& packet, const Node& destinationNode);
qint64 sendUnreliablePacket(const NLPacket& packet, const HifiSockAddr& sockAddr, HMACAuth* hmacAuth = nullptr);
qint64 sendUnreliablePacket(const NLPacket& packet, const SockAddr& sockAddr, HMACAuth* hmacAuth = nullptr);
// use sendPacket to send a moved unreliable or reliable NL packet to a node's active socket or manual sockaddr
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode);
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const HifiSockAddr& sockAddr, HMACAuth* hmacAuth = nullptr);
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const SockAddr& sockAddr, HMACAuth* hmacAuth = nullptr);
// use sendUnreliableUnorderedPacketList to unreliably send separate packets from the packet list
// either to a node's active socket or to a manual sockaddr
qint64 sendUnreliableUnorderedPacketList(NLPacketList& packetList, const Node& destinationNode);
qint64 sendUnreliableUnorderedPacketList(NLPacketList& packetList, const HifiSockAddr& sockAddr,
qint64 sendUnreliableUnorderedPacketList(NLPacketList& packetList, const SockAddr& sockAddr,
HMACAuth* hmacAuth = nullptr);
// use sendPacketList to send reliable packet lists (ordered or unordered) to a node's active socket
// or to a manual sock addr
qint64 sendPacketList(std::unique_ptr<NLPacketList> packetList, const HifiSockAddr& sockAddr);
qint64 sendPacketList(std::unique_ptr<NLPacketList> packetList, const SockAddr& sockAddr);
qint64 sendPacketList(std::unique_ptr<NLPacketList> packetList, const Node& destinationNode);
std::function<void(Node*)> linkedDataCreateCallback;
@ -175,7 +175,7 @@ public:
SharedNodePointer nodeWithLocalID(Node::LocalID localID) const;
SharedNodePointer addOrUpdateNode(const QUuid& uuid, NodeType_t nodeType,
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
const SockAddr& publicSocket, const SockAddr& localSocket,
Node::LocalID localID = Node::NULL_LOCAL_ID, bool isReplicated = false,
bool isUpstream = false, const QUuid& connectionSecret = QUuid(),
const NodePermissions& permissions = DEFAULT_AGENT_PERMISSIONS);
@ -183,9 +183,9 @@ public:
static bool parseSTUNResponse(udt::BasePacket* packet, QHostAddress& newPublicAddress, uint16_t& newPublicPort);
bool hasCompletedInitialSTUN() const { return _hasCompletedInitialSTUN; }
const HifiSockAddr& getLocalSockAddr() const { return _localSockAddr; }
const HifiSockAddr& getPublicSockAddr() const { return _publicSockAddr; }
const HifiSockAddr& getSTUNSockAddr() const { return _stunSockAddr; }
const SockAddr& getLocalSockAddr() const { return _localSockAddr; }
const SockAddr& getPublicSockAddr() const { return _publicSockAddr; }
const SockAddr& getSTUNSockAddr() const { return _stunSockAddr; }
void processKillNode(ReceivedMessage& message);
@ -201,9 +201,9 @@ public:
static std::unique_ptr<NLPacket> constructICEPingPacket(PingType_t pingType, const QUuid& iceID);
static std::unique_ptr<NLPacket> constructICEPingReplyPacket(ReceivedMessage& message, const QUuid& iceID);
void sendPeerQueryToIceServer(const HifiSockAddr& iceServerSockAddr, const QUuid& clientID, const QUuid& peerID);
void sendPeerQueryToIceServer(const SockAddr& iceServerSockAddr, const QUuid& clientID, const QUuid& peerID);
SharedNodePointer findNodeWithAddr(const HifiSockAddr& addr);
SharedNodePointer findNodeWithAddr(const SockAddr& addr);
using value_type = SharedNodePointer;
using const_iterator = std::vector<value_type>::const_iterator;
@ -369,7 +369,7 @@ private slots:
signals:
// QUuid might be zero for non-sourced packet types.
void packetVersionMismatch(PacketType type, const HifiSockAddr& senderSockAddr, const QUuid& senderUUID);
void packetVersionMismatch(PacketType type, const SockAddr& senderSockAddr, const QUuid& senderUUID);
void uuidChanged(const QUuid& ownerUUID, const QUuid& oldUUID);
void nodeAdded(SharedNodePointer);
@ -379,8 +379,8 @@ signals:
void clientConnectionToNodeReset(SharedNodePointer);
void localSockAddrChanged(const HifiSockAddr& localSockAddr);
void publicSockAddrChanged(const HifiSockAddr& publicSockAddr);
void localSockAddrChanged(const SockAddr& localSockAddr);
void publicSockAddrChanged(const SockAddr& publicSockAddr);
void isAllowedEditorChanged(bool isAllowedEditor);
void canRezChanged(bool canRez);
@ -397,7 +397,7 @@ protected slots:
void connectedForLocalSocketTest();
void errorTestingLocalSocket();
void clientConnectionToSockAddrReset(const HifiSockAddr& sockAddr);
void clientConnectionToSockAddrReset(const SockAddr& sockAddr);
void processDelayedAdds();
@ -405,8 +405,8 @@ protected:
struct NewNodeInfo {
qint8 type;
QUuid uuid;
HifiSockAddr publicSocket;
HifiSockAddr localSocket;
SockAddr publicSocket;
SockAddr localSocket;
NodePermissions permissions;
bool isReplicated;
Node::LocalID sessionLocalID;
@ -418,10 +418,10 @@ protected:
void operator=(LimitedNodeList const&) = delete; // Don't implement, needed to avoid copies of singleton
qint64 sendPacket(std::unique_ptr<NLPacket> packet, const Node& destinationNode,
const HifiSockAddr& overridenSockAddr);
const SockAddr& overridenSockAddr);
void fillPacketHeader(const NLPacket& packet, HMACAuth* hmacAuth = nullptr);
void setLocalSocket(const HifiSockAddr& sockAddr);
void setLocalSocket(const SockAddr& sockAddr);
bool packetSourceAndHashMatchAndTrackBandwidth(const udt::Packet& packet, Node* sourceNode = nullptr);
void processSTUNResponse(std::unique_ptr<udt::BasePacket> packet);
@ -430,10 +430,10 @@ protected:
void stopInitialSTUNUpdate(bool success);
void sendPacketToIceServer(PacketType packetType, const HifiSockAddr& iceServerSockAddr, const QUuid& clientID,
void sendPacketToIceServer(PacketType packetType, const SockAddr& iceServerSockAddr, const QUuid& clientID,
const QUuid& peerRequestID = QUuid());
bool sockAddrBelongsToNode(const HifiSockAddr& sockAddr);
bool sockAddrBelongsToNode(const SockAddr& sockAddr);
void addNewNode(NewNodeInfo info);
void delayNodeAdd(NewNodeInfo info);
@ -444,9 +444,9 @@ protected:
mutable QReadWriteLock _nodeMutex { QReadWriteLock::Recursive };
udt::Socket _nodeSocket;
QUdpSocket* _dtlsSocket { nullptr };
HifiSockAddr _localSockAddr;
HifiSockAddr _publicSockAddr;
HifiSockAddr _stunSockAddr { STUN_SERVER_HOSTNAME, STUN_SERVER_PORT };
SockAddr _localSockAddr;
SockAddr _publicSockAddr;
SockAddr _stunSockAddr { STUN_SERVER_HOSTNAME, STUN_SERVER_PORT };
bool _hasTCPCheckedLocalSocket { false };
bool _useAuthentication { true };

View file

@ -4,6 +4,7 @@
//
// Created by Clement on 7/6/15.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -35,7 +36,7 @@ std::unique_ptr<NLPacket> NLPacket::create(PacketType type, qint64 size, bool is
}
std::unique_ptr<NLPacket> NLPacket::fromReceivedPacket(std::unique_ptr<char[]> data, qint64 size,
const HifiSockAddr& senderSockAddr) {
const SockAddr& senderSockAddr) {
// Fail with null data
Q_ASSERT(data);
@ -89,7 +90,7 @@ NLPacket::NLPacket(const NLPacket& other) : Packet(other) {
_sourceID = other._sourceID;
}
NLPacket::NLPacket(std::unique_ptr<char[]> data, qint64 size, const HifiSockAddr& senderSockAddr) :
NLPacket::NLPacket(std::unique_ptr<char[]> data, qint64 size, const SockAddr& senderSockAddr) :
Packet(std::move(data), size, senderSockAddr)
{
// sanity check before we decrease the payloadSize with the payloadCapacity

View file

@ -4,6 +4,7 @@
//
// Created by Clement on 7/6/15.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -52,7 +53,7 @@ public:
bool isReliable = false, bool isPartOfMessage = false, PacketVersion version = 0);
static std::unique_ptr<NLPacket> fromReceivedPacket(std::unique_ptr<char[]> data, qint64 size,
const HifiSockAddr& senderSockAddr);
const SockAddr& senderSockAddr);
static std::unique_ptr<NLPacket> fromBase(std::unique_ptr<Packet> packet);
@ -87,7 +88,7 @@ public:
protected:
NLPacket(PacketType type, qint64 size = -1, bool forceReliable = false, bool isPartOfMessage = false, PacketVersion version = 0);
NLPacket(std::unique_ptr<char[]> data, qint64 size, const HifiSockAddr& senderSockAddr);
NLPacket(std::unique_ptr<char[]> data, qint64 size, const SockAddr& senderSockAddr);
NLPacket(const NLPacket& other);
NLPacket(NLPacket&& other);

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2014-10-02.
// Copyright 2014 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -37,7 +38,7 @@ NetworkPeer::NetworkPeer(QObject* parent) :
_lastHeardMicrostamp = usecTimestampNow();
}
NetworkPeer::NetworkPeer(const QUuid& uuid, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket, QObject* parent) :
NetworkPeer::NetworkPeer(const QUuid& uuid, const SockAddr& publicSocket, const SockAddr& localSocket, QObject* parent) :
QObject(parent),
_uuid(uuid),
_publicSocket(publicSocket),
@ -50,7 +51,7 @@ NetworkPeer::NetworkPeer(const QUuid& uuid, const HifiSockAddr& publicSocket, co
_lastHeardMicrostamp = usecTimestampNow();
}
void NetworkPeer::setPublicSocket(const HifiSockAddr& publicSocket) {
void NetworkPeer::setPublicSocket(const SockAddr& publicSocket) {
if (publicSocket != _publicSocket) {
if (_activeSocket == &_publicSocket) {
// if the active socket was the public socket then reset it to NULL
@ -70,7 +71,7 @@ void NetworkPeer::setPublicSocket(const HifiSockAddr& publicSocket) {
}
}
void NetworkPeer::setLocalSocket(const HifiSockAddr& localSocket) {
void NetworkPeer::setLocalSocket(const SockAddr& localSocket) {
if (localSocket != _localSocket) {
if (_activeSocket == &_localSocket) {
// if the active socket was the local socket then reset it to NULL
@ -90,7 +91,7 @@ void NetworkPeer::setLocalSocket(const HifiSockAddr& localSocket) {
}
}
void NetworkPeer::setSymmetricSocket(const HifiSockAddr& symmetricSocket) {
void NetworkPeer::setSymmetricSocket(const SockAddr& symmetricSocket) {
if (symmetricSocket != _symmetricSocket) {
if (_activeSocket == &_symmetricSocket) {
// if the active socket was the symmetric socket then reset it to NULL
@ -110,7 +111,7 @@ void NetworkPeer::setSymmetricSocket(const HifiSockAddr& symmetricSocket) {
}
}
void NetworkPeer::setActiveSocket(HifiSockAddr* discoveredSocket) {
void NetworkPeer::setActiveSocket(SockAddr* discoveredSocket) {
_activeSocket = discoveredSocket;
// we have an active socket, stop our ping timer
@ -145,7 +146,7 @@ void NetworkPeer::activateSymmetricSocket() {
}
}
void NetworkPeer::activateMatchingOrNewSymmetricSocket(const HifiSockAddr& matchableSockAddr) {
void NetworkPeer::activateMatchingOrNewSymmetricSocket(const SockAddr& matchableSockAddr) {
if (matchableSockAddr == _publicSocket) {
activatePublicSocket();
} else if (matchableSockAddr == _localSocket) {

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2014-10-02.
// Copyright 2014 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -18,7 +19,7 @@
#include <QtCore/QTimer>
#include <QtCore/QUuid>
#include "HifiSockAddr.h"
#include "SockAddr.h"
#include "UUID.h"
const QString ICE_SERVER_HOSTNAME = "localhost";
@ -32,7 +33,7 @@ class NetworkPeer : public QObject {
Q_OBJECT
public:
NetworkPeer(QObject* parent = 0);
NetworkPeer(const QUuid& uuid, const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket, QObject* parent = 0);
NetworkPeer(const QUuid& uuid, const SockAddr& publicSocket, const SockAddr& localSocket, QObject* parent = 0);
bool isNull() const { return _uuid.isNull(); }
bool hasSockets() const { return !_localSocket.isNull() && !_publicSocket.isNull(); }
@ -49,21 +50,21 @@ public:
void softReset();
void reset();
const HifiSockAddr& getPublicSocket() const { return _publicSocket; }
const HifiSockAddr& getLocalSocket() const { return _localSocket; }
const HifiSockAddr& getSymmetricSocket() const { return _symmetricSocket; }
const SockAddr& getPublicSocket() const { return _publicSocket; }
const SockAddr& getLocalSocket() const { return _localSocket; }
const SockAddr& getSymmetricSocket() const { return _symmetricSocket; }
void setPublicSocket(const HifiSockAddr& publicSocket);
void setLocalSocket(const HifiSockAddr& localSocket);
void setSymmetricSocket(const HifiSockAddr& symmetricSocket);
void setPublicSocket(const SockAddr& publicSocket);
void setLocalSocket(const SockAddr& localSocket);
void setSymmetricSocket(const SockAddr& symmetricSocket);
const HifiSockAddr* getActiveSocket() const { return _activeSocket; }
const SockAddr* getActiveSocket() const { return _activeSocket; }
void activatePublicSocket();
void activateLocalSocket();
void activateSymmetricSocket();
void activateMatchingOrNewSymmetricSocket(const HifiSockAddr& matchableSockAddr);
void activateMatchingOrNewSymmetricSocket(const SockAddr& matchableSockAddr);
quint64 getWakeTimestamp() const { return _wakeTimestamp; }
void setWakeTimestamp(quint64 wakeTimestamp) { _wakeTimestamp = wakeTimestamp; }
@ -93,19 +94,19 @@ public slots:
signals:
void pingTimerTimeout();
void socketActivated(const HifiSockAddr& sockAddr);
void socketUpdated(HifiSockAddr previousAddress, HifiSockAddr currentAddress);
void socketActivated(const SockAddr& sockAddr);
void socketUpdated(SockAddr previousAddress, SockAddr currentAddress);
protected:
void setActiveSocket(HifiSockAddr* discoveredSocket);
void setActiveSocket(SockAddr* discoveredSocket);
QUuid _uuid;
LocalID _localID { 0 };
HifiSockAddr _publicSocket;
HifiSockAddr _localSocket;
HifiSockAddr _symmetricSocket;
HifiSockAddr* _activeSocket;
SockAddr _publicSocket;
SockAddr _localSocket;
SockAddr _symmetricSocket;
SockAddr* _activeSocket;
quint64 _wakeTimestamp;
std::atomic_ullong _lastHeardMicrostamp;

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2/15/13.
// Copyright 2013 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -85,8 +86,8 @@ NodeType_t NodeType::fromString(QString type) {
}
Node::Node(const QUuid& uuid, NodeType_t type, const HifiSockAddr& publicSocket,
const HifiSockAddr& localSocket, QObject* parent) :
Node::Node(const QUuid& uuid, NodeType_t type, const SockAddr& publicSocket,
const SockAddr& localSocket, QObject* parent) :
NetworkPeer(uuid, publicSocket, localSocket, parent),
_type(type),
_pingMs(-1), // "Uninitialized"

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2/15/13.
// Copyright 2013 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -27,7 +28,7 @@
#include <TBBHelpers.h>
#include "HifiSockAddr.h"
#include "SockAddr.h"
#include "NetworkPeer.h"
#include "NodeData.h"
#include "NodeType.h"
@ -44,7 +45,7 @@ public:
using Stats = udt::ConnectionStats::Stats;
Node(const QUuid& uuid, NodeType_t type,
const HifiSockAddr& publicSocket, const HifiSockAddr& localSocket,
const SockAddr& publicSocket, const SockAddr& localSocket,
QObject* parent = nullptr);
bool operator==(const Node& otherNode) const { return _uuid == otherNode._uuid; }

View file

@ -35,7 +35,7 @@
#include "Assignment.h"
#include "AudioHelpers.h"
#include "DomainAccountManager.h"
#include "HifiSockAddr.h"
#include "SockAddr.h"
#include "FingerprintUtils.h"
#include "NetworkLogging.h"
@ -176,11 +176,11 @@ NodeList::NodeList(char newOwnerType, int socketListenPort, int dtlsListenPort)
PacketReceiver::makeUnsourcedListenerReference<NodeList>(this, &NodeList::processUsernameFromIDReply));
}
qint64 NodeList::sendStats(QJsonObject statsObject, HifiSockAddr destination) {
qint64 NodeList::sendStats(QJsonObject statsObject, SockAddr destination) {
if (thread() != QThread::currentThread()) {
QMetaObject::invokeMethod(this, "sendStats", Qt::QueuedConnection,
Q_ARG(QJsonObject, statsObject),
Q_ARG(HifiSockAddr, destination));
Q_ARG(SockAddr, destination));
return 0;
}
@ -245,7 +245,7 @@ void NodeList::timePingReply(ReceivedMessage& message, const SharedNodePointer&
void NodeList::processPingPacket(QSharedPointer<ReceivedMessage> message, SharedNodePointer sendingNode) {
// send back a reply
auto replyPacket = constructPingReplyPacket(*message);
const HifiSockAddr& senderSockAddr = message->getSenderSockAddr();
const SockAddr& senderSockAddr = message->getSenderSockAddr();
sendPacket(std::move(replyPacket), *sendingNode, senderSockAddr);
// If we don't have a symmetric socket for this node and this socket doesn't match
@ -364,7 +364,7 @@ void NodeList::sendDomainServerCheckIn() {
// let the domain handler know we are due to send a checkin packet
} else if (!domainHandlerIp.isNull() && !_domainHandler.checkInPacketTimeout()) {
bool domainIsConnected = _domainHandler.isConnected();
HifiSockAddr domainSockAddr = _domainHandler.getSockAddr();
SockAddr domainSockAddr = _domainHandler.getSockAddr();
PacketType domainPacketType = !domainIsConnected
? PacketType::DomainConnectRequest : PacketType::DomainListRequest;
@ -405,7 +405,7 @@ void NodeList::sendDomainServerCheckIn() {
QDataStream packetStream(domainPacket.get());
HifiSockAddr localSockAddr = _localSockAddr;
SockAddr localSockAddr = _localSockAddr;
if (domainPacketType == PacketType::DomainConnectRequest) {
#if (PR_BUILD || DEV_BUILD)
@ -1012,7 +1012,7 @@ void NodeList::sendKeepAlivePings() {
});
}
bool NodeList::sockAddrBelongsToDomainOrNode(const HifiSockAddr& sockAddr) {
bool NodeList::sockAddrBelongsToDomainOrNode(const SockAddr& sockAddr) {
return _domainHandler.getSockAddr() == sockAddr || LimitedNodeList::sockAddrBelongsToNode(sockAddr);
}

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2/15/13.
// Copyright 2013 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -57,7 +58,7 @@ public:
NodeType_t getOwnerType() const { return _ownerType.load(); }
void setOwnerType(NodeType_t ownerType) { _ownerType.store(ownerType); }
Q_INVOKABLE qint64 sendStats(QJsonObject statsObject, HifiSockAddr destination);
Q_INVOKABLE qint64 sendStats(QJsonObject statsObject, SockAddr destination);
Q_INVOKABLE qint64 sendStatsToDomainServer(QJsonObject statsObject);
DomainHandler& getDomainHandler() { return _domainHandler; }
@ -67,7 +68,7 @@ public:
void addSetOfNodeTypesToNodeInterestSet(const NodeSet& setOfNodeTypes);
void resetNodeInterestSet() { _nodeTypesOfInterest.clear(); }
void setAssignmentServerSocket(const HifiSockAddr& serverSocket) { _assignmentServerSocket = serverSocket; }
void setAssignmentServerSocket(const SockAddr& serverSocket) { _assignmentServerSocket = serverSocket; }
void sendAssignment(Assignment& assignment);
void setIsShuttingDown(bool isShuttingDown) { _isShuttingDown = isShuttingDown; }
@ -100,7 +101,7 @@ public:
virtual bool isDomainServer() const override { return false; }
virtual QUuid getDomainUUID() const override { return _domainHandler.getUUID(); }
virtual Node::LocalID getDomainLocalID() const override { return _domainHandler.getLocalID(); }
virtual HifiSockAddr getDomainSockAddr() const override { return _domainHandler.getSockAddr(); }
virtual SockAddr getDomainSockAddr() const override { return _domainHandler.getSockAddr(); }
public slots:
void reset(QString reason, bool skipDomainHandlerReset = false);
@ -169,12 +170,12 @@ private:
void pingPunchForInactiveNode(const SharedNodePointer& node);
bool sockAddrBelongsToDomainOrNode(const HifiSockAddr& sockAddr);
bool sockAddrBelongsToDomainOrNode(const SockAddr& sockAddr);
std::atomic<NodeType_t> _ownerType;
NodeSet _nodeTypesOfInterest;
DomainHandler _domainHandler;
HifiSockAddr _assignmentServerSocket;
SockAddr _assignmentServerSocket;
bool _isShuttingDown { false };
QTimer _keepAlivePingTimer;
bool _requestsDomainListData { false };

View file

@ -5,6 +5,7 @@
// Created by Stephen Birarda on 1/23/2014.
// Update by Ryan Huffman on 7/8/2015.
// Copyright 2014 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -152,7 +153,7 @@ void PacketReceiver::handleVerifiedPacket(std::unique_ptr<udt::Packet> packet) {
void PacketReceiver::handleVerifiedMessagePacket(std::unique_ptr<udt::Packet> packet) {
auto nlPacket = NLPacket::fromBase(std::move(packet));
auto key = std::pair<HifiSockAddr, udt::Packet::MessageNumber>(nlPacket->getSenderSockAddr(), nlPacket->getMessageNumber());
auto key = std::pair<SockAddr, udt::Packet::MessageNumber>(nlPacket->getSenderSockAddr(), nlPacket->getMessageNumber());
auto it = _pendingMessages.find(key);
QSharedPointer<ReceivedMessage> message;
@ -174,8 +175,8 @@ void PacketReceiver::handleVerifiedMessagePacket(std::unique_ptr<udt::Packet> pa
}
}
void PacketReceiver::handleMessageFailure(HifiSockAddr from, udt::Packet::MessageNumber messageNumber) {
auto key = std::pair<HifiSockAddr, udt::Packet::MessageNumber>(from, messageNumber);
void PacketReceiver::handleMessageFailure(SockAddr from, udt::Packet::MessageNumber messageNumber) {
auto key = std::pair<SockAddr, udt::Packet::MessageNumber>(from, messageNumber);
auto it = _pendingMessages.find(key);
if (it != _pendingMessages.end()) {
auto message = it->second;

View file

@ -5,6 +5,7 @@
// Created by Stephen Birarda on 1/23/2014.
// Update by Ryan Huffman on 7/8/2015.
// Copyright 2014 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -34,9 +35,9 @@ class OctreePacketProcessor;
namespace std {
template <>
struct hash<std::pair<HifiSockAddr, udt::Packet::MessageNumber>> {
size_t operator()(const std::pair<HifiSockAddr, udt::Packet::MessageNumber>& pair) const {
return hash<HifiSockAddr>()(pair.first) ^ hash<udt::Packet::MessageNumber>()(pair.second);
struct hash<std::pair<SockAddr, udt::Packet::MessageNumber>> {
size_t operator()(const std::pair<SockAddr, udt::Packet::MessageNumber>& pair) const {
return hash<SockAddr>()(pair.first) ^ hash<udt::Packet::MessageNumber>()(pair.second);
}
};
}
@ -78,7 +79,7 @@ public:
void handleVerifiedPacket(std::unique_ptr<udt::Packet> packet);
void handleVerifiedMessagePacket(std::unique_ptr<udt::Packet> message);
void handleMessageFailure(HifiSockAddr from, udt::Packet::MessageNumber messageNumber);
void handleMessageFailure(SockAddr from, udt::Packet::MessageNumber messageNumber);
private:
template <class T>
@ -129,7 +130,7 @@ private:
QMutex _directConnectSetMutex;
QSet<QObject*> _directlyConnectedObjects;
std::unordered_map<std::pair<HifiSockAddr, udt::Packet::MessageNumber>, QSharedPointer<ReceivedMessage>> _pendingMessages;
std::unordered_map<std::pair<SockAddr, udt::Packet::MessageNumber>, QSharedPointer<ReceivedMessage>> _pendingMessages;
friend class EntityEditPacketSender;
friend class OctreePacketProcessor;

View file

@ -4,6 +4,7 @@
//
// Created by Ryan Huffman on 2015/09/17
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -49,7 +50,7 @@ ReceivedMessage::ReceivedMessage(NLPacket& packet)
}
ReceivedMessage::ReceivedMessage(QByteArray byteArray, PacketType packetType, PacketVersion packetVersion,
const HifiSockAddr& senderSockAddr, NLPacket::LocalID sourceID) :
const SockAddr& senderSockAddr, NLPacket::LocalID sourceID) :
_data(byteArray),
_headData(_data.mid(0, HEAD_DATA_SIZE)),
_numPackets(1),

View file

@ -4,6 +4,7 @@
//
// Created by Ryan Huffman on 2015/09/15
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -25,7 +26,7 @@ public:
ReceivedMessage(const NLPacketList& packetList);
ReceivedMessage(NLPacket& packet);
ReceivedMessage(QByteArray byteArray, PacketType packetType, PacketVersion packetVersion,
const HifiSockAddr& senderSockAddr, NLPacket::LocalID sourceID = NLPacket::NULL_LOCAL_ID);
const SockAddr& senderSockAddr, NLPacket::LocalID sourceID = NLPacket::NULL_LOCAL_ID);
QByteArray getMessage() const { return _data; }
const char* getRawMessage() const { return _data.constData(); }
@ -41,7 +42,7 @@ public:
bool isComplete() const { return _isComplete; }
NLPacket::LocalID getSourceID() const { return _sourceID; }
const HifiSockAddr& getSenderSockAddr() { return _senderSockAddr; }
const SockAddr& getSenderSockAddr() { return _senderSockAddr; }
qint64 getPosition() const { return _position; }
@ -99,7 +100,7 @@ private:
NLPacket::LocalID _sourceID { NLPacket::NULL_LOCAL_ID };
PacketType _packetType;
PacketVersion _packetVersion;
HifiSockAddr _senderSockAddr;
SockAddr _senderSockAddr;
std::atomic<bool> _isComplete { true };
std::atomic<bool> _failed { false };

View file

@ -1,15 +1,16 @@
//
// HifiSockAddr.cpp
// SockAddr.cpp
// libraries/networking/src
//
// Created by Stephen Birarda on 11/26/2013.
// Copyright 2013 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "HifiSockAddr.h"
#include "SockAddr.h"
#include <qdatastream.h>
#include <qhostinfo.h>
@ -24,23 +25,23 @@
#include <netinet/in.h>
#endif
int hifiSockAddrMetaTypeId = qRegisterMetaType<HifiSockAddr>();
int sockAddrMetaTypeId = qRegisterMetaType<SockAddr>();
HifiSockAddr::HifiSockAddr() :
SockAddr::SockAddr() :
_address(),
_port(0)
{
}
HifiSockAddr::HifiSockAddr(const QHostAddress& address, quint16 port) :
SockAddr::SockAddr(const QHostAddress& address, quint16 port) :
_address(address),
_port(port)
{
}
HifiSockAddr::HifiSockAddr(const HifiSockAddr& otherSockAddr) :
SockAddr::SockAddr(const SockAddr& otherSockAddr) :
QObject(),
_address(otherSockAddr._address),
_port(otherSockAddr._port)
@ -48,14 +49,14 @@ HifiSockAddr::HifiSockAddr(const HifiSockAddr& otherSockAddr) :
setObjectName(otherSockAddr.objectName());
}
HifiSockAddr& HifiSockAddr::operator=(const HifiSockAddr& rhsSockAddr) {
SockAddr& SockAddr::operator=(const SockAddr& rhsSockAddr) {
setObjectName(rhsSockAddr.objectName());
_address = rhsSockAddr._address;
_port = rhsSockAddr._port;
return *this;
}
HifiSockAddr::HifiSockAddr(const QString& hostname, quint16 hostOrderPort, bool shouldBlockForLookup) :
SockAddr::SockAddr(const QString& hostname, quint16 hostOrderPort, bool shouldBlockForLookup) :
_address(hostname),
_port(hostOrderPort)
{
@ -73,7 +74,7 @@ HifiSockAddr::HifiSockAddr(const QString& hostname, quint16 hostOrderPort, bool
}
}
HifiSockAddr::HifiSockAddr(const sockaddr* sockaddr) {
SockAddr::SockAddr(const sockaddr* sockaddr) {
_address = QHostAddress(sockaddr);
if (sockaddr->sa_family == AF_INET) {
@ -83,7 +84,7 @@ HifiSockAddr::HifiSockAddr(const sockaddr* sockaddr) {
}
}
void HifiSockAddr::swap(HifiSockAddr& otherSockAddr) {
void SockAddr::swap(SockAddr& otherSockAddr) {
using std::swap;
swap(_address, otherSockAddr._address);
@ -95,11 +96,11 @@ void HifiSockAddr::swap(HifiSockAddr& otherSockAddr) {
setObjectName(temp);
}
bool HifiSockAddr::operator==(const HifiSockAddr& rhsSockAddr) const {
bool SockAddr::operator==(const SockAddr& rhsSockAddr) const {
return _address == rhsSockAddr._address && _port == rhsSockAddr._port;
}
void HifiSockAddr::handleLookupResult(const QHostInfo& hostInfo) {
void SockAddr::handleLookupResult(const QHostInfo& hostInfo) {
if (hostInfo.error() != QHostInfo::NoError) {
qCDebug(networking) << "Lookup failed for" << hostInfo.lookupId() << ":" << hostInfo.errorString();
emit lookupFailed();
@ -117,11 +118,11 @@ void HifiSockAddr::handleLookupResult(const QHostInfo& hostInfo) {
}
}
QString HifiSockAddr::toString() const {
QString SockAddr::toString() const {
return _address.toString() + ":" + QString::number(_port);
}
bool HifiSockAddr::hasPrivateAddress() const {
bool SockAddr::hasPrivateAddress() const {
// an address is private if it is loopback or falls in any of the RFC1918 address spaces
const QPair<QHostAddress, int> TWENTY_FOUR_BIT_BLOCK = { QHostAddress("10.0.0.0"), 8 };
const QPair<QHostAddress, int> TWENTY_BIT_BLOCK = { QHostAddress("172.16.0.0") , 12 };
@ -133,22 +134,22 @@ bool HifiSockAddr::hasPrivateAddress() const {
|| _address.isInSubnet(SIXTEEN_BIT_BLOCK);
}
QDebug operator<<(QDebug debug, const HifiSockAddr& sockAddr) {
QDebug operator<<(QDebug debug, const SockAddr& sockAddr) {
debug.nospace() << sockAddr._address.toString().toLocal8Bit().constData() << ":" << sockAddr._port;
return debug.space();
}
QDataStream& operator<<(QDataStream& dataStream, const HifiSockAddr& sockAddr) {
QDataStream& operator<<(QDataStream& dataStream, const SockAddr& sockAddr) {
dataStream << sockAddr._address << sockAddr._port;
return dataStream;
}
QDataStream& operator>>(QDataStream& dataStream, HifiSockAddr& sockAddr) {
QDataStream& operator>>(QDataStream& dataStream, SockAddr& sockAddr) {
dataStream >> sockAddr._address >> sockAddr._port;
return dataStream;
}
uint qHash(const HifiSockAddr& key, uint seed) {
uint qHash(const SockAddr& key, uint seed) {
// use the existing QHostAddress and quint16 hash functions to get our hash
return qHash(key.getAddress(), seed) ^ qHash(key.getPort(), seed);
}

View file

@ -1,16 +1,17 @@
//
// HifiSockAddr.h
// SockAddr.h
// libraries/networking/src
//
// Created by Stephen Birarda on 11/26/2013.
// Copyright 2013 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_HifiSockAddr_h
#define hifi_HifiSockAddr_h
#ifndef hifi_SockAddr_h
#define hifi_SockAddr_h
#include <cstdint>
#include <string>
@ -19,23 +20,23 @@ struct sockaddr;
#include <QtNetwork/QHostInfo>
class HifiSockAddr : public QObject {
class SockAddr : public QObject {
Q_OBJECT
public:
HifiSockAddr();
HifiSockAddr(const QHostAddress& address, quint16 port);
HifiSockAddr(const HifiSockAddr& otherSockAddr);
HifiSockAddr(const QString& hostname, quint16 hostOrderPort, bool shouldBlockForLookup = false);
HifiSockAddr(const sockaddr* sockaddr);
SockAddr();
SockAddr(const QHostAddress& address, quint16 port);
SockAddr(const SockAddr& otherSockAddr);
SockAddr(const QString& hostname, quint16 hostOrderPort, bool shouldBlockForLookup = false);
SockAddr(const sockaddr* sockaddr);
bool isNull() const { return _address.isNull() && _port == 0; }
void clear() { _address.clear(); _port = 0;}
HifiSockAddr& operator=(const HifiSockAddr& rhsSockAddr);
void swap(HifiSockAddr& otherSockAddr);
SockAddr& operator=(const SockAddr& rhsSockAddr);
void swap(SockAddr& otherSockAddr);
bool operator==(const HifiSockAddr& rhsSockAddr) const;
bool operator!=(const HifiSockAddr& rhsSockAddr) const { return !(*this == rhsSockAddr); }
bool operator==(const SockAddr& rhsSockAddr) const;
bool operator!=(const SockAddr& rhsSockAddr) const { return !(*this == rhsSockAddr); }
const QHostAddress& getAddress() const { return _address; }
QHostAddress* getAddressPointer() { return &_address; }
@ -45,16 +46,16 @@ public:
quint16* getPortPointer() { return &_port; }
void setPort(quint16 port) { _port = port; }
static int packSockAddr(unsigned char* packetData, const HifiSockAddr& packSockAddr);
static int unpackSockAddr(const unsigned char* packetData, HifiSockAddr& unpackDestSockAddr);
static int packSockAddr(unsigned char* packetData, const SockAddr& packSockAddr);
static int unpackSockAddr(const unsigned char* packetData, SockAddr& unpackDestSockAddr);
QString toString() const;
bool hasPrivateAddress() const; // checks if the address behind this sock addr is private per RFC 1918
friend QDebug operator<<(QDebug debug, const HifiSockAddr& sockAddr);
friend QDataStream& operator<<(QDataStream& dataStream, const HifiSockAddr& sockAddr);
friend QDataStream& operator>>(QDataStream& dataStream, HifiSockAddr& sockAddr);
friend QDebug operator<<(QDebug debug, const SockAddr& sockAddr);
friend QDataStream& operator<<(QDataStream& dataStream, const SockAddr& sockAddr);
friend QDataStream& operator>>(QDataStream& dataStream, SockAddr& sockAddr);
private slots:
void handleLookupResult(const QHostInfo& hostInfo);
@ -66,14 +67,14 @@ private:
quint16 _port;
};
uint qHash(const HifiSockAddr& key, uint seed);
uint qHash(const SockAddr& key, uint seed);
namespace std {
template <>
struct hash<HifiSockAddr> {
struct hash<SockAddr> {
// NOTE: this hashing specifically ignores IPv6 addresses - if we begin to support those we will need
// to conditionally hash the bytes that represent an IPv6 address
size_t operator()(const HifiSockAddr& sockAddr) const {
size_t operator()(const SockAddr& sockAddr) const {
// use XOR of implemented std::hash templates for new hash
// depending on the type of address we're looking at
@ -90,6 +91,6 @@ namespace std {
};
}
Q_DECLARE_METATYPE(HifiSockAddr);
Q_DECLARE_METATYPE(SockAddr);
#endif // hifi_HifiSockAddr_h
#endif // hifi_SockAddr_h

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2015-07-23.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -36,7 +37,7 @@ std::unique_ptr<BasePacket> BasePacket::create(qint64 size) {
}
std::unique_ptr<BasePacket> BasePacket::fromReceivedPacket(std::unique_ptr<char[]> data,
qint64 size, const HifiSockAddr& senderSockAddr) {
qint64 size, const SockAddr& senderSockAddr) {
// Fail with invalid size
Q_ASSERT(size >= 0);
@ -66,7 +67,7 @@ BasePacket::BasePacket(qint64 size) {
_payloadStart = _packet.get();
}
BasePacket::BasePacket(std::unique_ptr<char[]> data, qint64 size, const HifiSockAddr& senderSockAddr) :
BasePacket::BasePacket(std::unique_ptr<char[]> data, qint64 size, const SockAddr& senderSockAddr) :
_packetSize(size),
_packet(std::move(data)),
_payloadStart(_packet.get()),

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2015-07-23.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -18,7 +19,7 @@
#include <PortableHighResolutionClock.h>
#include "../HifiSockAddr.h"
#include "../SockAddr.h"
#include "Constants.h"
#include "../ExtendedIODevice.h"
@ -31,7 +32,7 @@ public:
static std::unique_ptr<BasePacket> create(qint64 size = -1);
static std::unique_ptr<BasePacket> fromReceivedPacket(std::unique_ptr<char[]> data, qint64 size,
const HifiSockAddr& senderSockAddr);
const SockAddr& senderSockAddr);
// Current level's header size
static int localHeaderSize();
@ -66,8 +67,8 @@ public:
qint64 bytesLeftToRead() const { return _payloadSize - pos(); }
qint64 bytesAvailableForWrite() const { return _payloadCapacity - pos(); }
HifiSockAddr& getSenderSockAddr() { return _senderSockAddr; }
const HifiSockAddr& getSenderSockAddr() const { return _senderSockAddr; }
SockAddr& getSenderSockAddr() { return _senderSockAddr; }
const SockAddr& getSenderSockAddr() const { return _senderSockAddr; }
// QIODevice virtual functions
// WARNING: Those methods all refer to the payload ONLY and NOT the entire packet
@ -87,7 +88,7 @@ public:
protected:
BasePacket(qint64 size);
BasePacket(std::unique_ptr<char[]> data, qint64 size, const HifiSockAddr& senderSockAddr);
BasePacket(std::unique_ptr<char[]> data, qint64 size, const SockAddr& senderSockAddr);
BasePacket(const BasePacket& other) : ExtendedIODevice() { *this = other; }
BasePacket& operator=(const BasePacket& other);
BasePacket(BasePacket&& other);
@ -107,7 +108,7 @@ protected:
qint64 _payloadSize = 0; // How much of the payload is actually used
HifiSockAddr _senderSockAddr; // sender address for packet (only used on receiving end)
SockAddr _senderSockAddr; // sender address for packet (only used on receiving end)
p_high_resolution_clock::time_point _receiveTime; // captures the time the packet received (only used on receiving end)
};

View file

@ -4,6 +4,7 @@
//
// Created by Clement on 7/27/15.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -17,7 +18,7 @@
#include <NumericalConstants.h>
#include "../HifiSockAddr.h"
#include "../SockAddr.h"
#include "../NetworkLogging.h"
#include "CongestionControl.h"
@ -30,7 +31,7 @@
using namespace udt;
using namespace std::chrono;
Connection::Connection(Socket* parentSocket, HifiSockAddr destination, std::unique_ptr<CongestionControl> congestionControl) :
Connection::Connection(Socket* parentSocket, SockAddr destination, std::unique_ptr<CongestionControl> congestionControl) :
_parentSocket(parentSocket),
_destination(destination),
_congestionControl(move(congestionControl))
@ -485,7 +486,7 @@ std::unique_ptr<Packet> PendingReceivedMessage::removeNextPacket() {
return std::unique_ptr<Packet>();
}
void Connection::setDestinationAddress(const HifiSockAddr& destination) {
void Connection::setDestinationAddress(const SockAddr& destination) {
if (_destination != destination) {
_destination = destination;
emit destinationAddressChange(destination);

View file

@ -4,6 +4,7 @@
//
// Created by Clement on 7/27/15.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -23,7 +24,7 @@
#include "Constants.h"
#include "LossList.h"
#include "SendQueue.h"
#include "../HifiSockAddr.h"
#include "../SockAddr.h"
namespace udt {
@ -52,7 +53,7 @@ class Connection : public QObject {
public:
using ControlPacketPointer = std::unique_ptr<ControlPacket>;
Connection(Socket* parentSocket, HifiSockAddr destination, std::unique_ptr<CongestionControl> congestionControl);
Connection(Socket* parentSocket, SockAddr destination, std::unique_ptr<CongestionControl> congestionControl);
virtual ~Connection();
void sendReliablePacket(std::unique_ptr<Packet> packet);
@ -68,7 +69,7 @@ public:
ConnectionStats::Stats sampleStats() { return _stats.sample(); }
HifiSockAddr getDestination() const { return _destination; }
SockAddr getDestination() const { return _destination; }
void setMaxBandwidth(int maxBandwidth);
@ -77,12 +78,12 @@ public:
void recordSentUnreliablePackets(int wireSize, int payloadSize);
void recordReceivedUnreliablePackets(int wireSize, int payloadSize);
void setDestinationAddress(const HifiSockAddr& destination);
void setDestinationAddress(const SockAddr& destination);
signals:
void packetSent();
void receiverHandshakeRequestComplete(const HifiSockAddr& sockAddr);
void destinationAddressChange(HifiSockAddr currentAddress);
void receiverHandshakeRequestComplete(const SockAddr& sockAddr);
void destinationAddressChange(SockAddr currentAddress);
private slots:
void recordSentPackets(int wireSize, int payloadSize, SequenceNumber seqNum, p_high_resolution_clock::time_point timePoint);
@ -124,7 +125,7 @@ private:
SequenceNumber _lastReceivedACK; // The last ACK received
Socket* _parentSocket { nullptr };
HifiSockAddr _destination;
SockAddr _destination;
std::unique_ptr<CongestionControl> _congestionControl;

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2015-07-24.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -26,7 +27,7 @@ int ControlPacket::maxPayloadSize() {
}
std::unique_ptr<ControlPacket> ControlPacket::fromReceivedPacket(std::unique_ptr<char[]> data, qint64 size,
const HifiSockAddr &senderSockAddr) {
const SockAddr &senderSockAddr) {
// Fail with null data
Q_ASSERT(data);
@ -56,7 +57,7 @@ ControlPacket::ControlPacket(Type type, qint64 size) :
writeType();
}
ControlPacket::ControlPacket(std::unique_ptr<char[]> data, qint64 size, const HifiSockAddr& senderSockAddr) :
ControlPacket::ControlPacket(std::unique_ptr<char[]> data, qint64 size, const SockAddr& senderSockAddr) :
BasePacket(std::move(data), size, senderSockAddr)
{
// sanity check before we decrease the payloadSize with the payloadCapacity

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2015-07-24.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -35,7 +36,7 @@ public:
static std::unique_ptr<ControlPacket> create(Type type, qint64 size = -1);
static std::unique_ptr<ControlPacket> fromReceivedPacket(std::unique_ptr<char[]> data, qint64 size,
const HifiSockAddr& senderSockAddr);
const SockAddr& senderSockAddr);
// Current level's header size
static int localHeaderSize();
// Cumulated size of all the headers
@ -48,7 +49,7 @@ public:
private:
ControlPacket(Type type, qint64 size = -1);
ControlPacket(std::unique_ptr<char[]> data, qint64 size, const HifiSockAddr& senderSockAddr);
ControlPacket(std::unique_ptr<char[]> data, qint64 size, const SockAddr& senderSockAddr);
ControlPacket(ControlPacket&& other);
ControlPacket(const ControlPacket& other) = delete;

View file

@ -4,6 +4,7 @@
//
// Created by Clement on 7/2/15.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -61,7 +62,7 @@ std::unique_ptr<Packet> Packet::create(qint64 size, bool isReliable, bool isPart
return packet;
}
std::unique_ptr<Packet> Packet::fromReceivedPacket(std::unique_ptr<char[]> data, qint64 size, const HifiSockAddr& senderSockAddr) {
std::unique_ptr<Packet> Packet::fromReceivedPacket(std::unique_ptr<char[]> data, qint64 size, const SockAddr& senderSockAddr) {
// Fail with invalid size
Q_ASSERT(size >= 0);
@ -87,7 +88,7 @@ Packet::Packet(qint64 size, bool isReliable, bool isPartOfMessage) :
writeHeader();
}
Packet::Packet(std::unique_ptr<char[]> data, qint64 size, const HifiSockAddr& senderSockAddr) :
Packet::Packet(std::unique_ptr<char[]> data, qint64 size, const SockAddr& senderSockAddr) :
BasePacket(std::move(data), size, senderSockAddr)
{
readHeader();

View file

@ -4,6 +4,7 @@
//
// Created by Clement on 7/2/15.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -69,7 +70,7 @@ public:
};
static std::unique_ptr<Packet> create(qint64 size = -1, bool isReliable = false, bool isPartOfMessage = false);
static std::unique_ptr<Packet> fromReceivedPacket(std::unique_ptr<char[]> data, qint64 size, const HifiSockAddr& senderSockAddr);
static std::unique_ptr<Packet> fromReceivedPacket(std::unique_ptr<char[]> data, qint64 size, const SockAddr& senderSockAddr);
// Provided for convenience, try to limit use
static std::unique_ptr<Packet> createCopy(const Packet& other);
@ -97,7 +98,7 @@ public:
protected:
Packet(qint64 size, bool isReliable = false, bool isPartOfMessage = false);
Packet(std::unique_ptr<char[]> data, qint64 size, const HifiSockAddr& senderSockAddr);
Packet(std::unique_ptr<char[]> data, qint64 size, const SockAddr& senderSockAddr);
Packet(const Packet& other);
Packet(Packet&& other);

View file

@ -4,6 +4,7 @@
//
// Created by Clement on 7/13/15.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -53,8 +54,8 @@ PacketList::PacketList(PacketList&& other) :
{
}
HifiSockAddr PacketList::getSenderSockAddr() const {
return _packets.size() > 0 ? _packets.front()->getSenderSockAddr() : HifiSockAddr();
SockAddr PacketList::getSenderSockAddr() const {
return _packets.size() > 0 ? _packets.front()->getSenderSockAddr() : SockAddr();
}
void PacketList::startSegment() {

View file

@ -4,6 +4,7 @@
//
// Created by Clement on 7/13/15.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -50,7 +51,7 @@ public:
virtual qint64 getMaxSegmentSize() const { return Packet::maxPayloadSize(_isOrdered); }
HifiSockAddr getSenderSockAddr() const;
SockAddr getSenderSockAddr() const;
void closeCurrentPacket(bool shouldSendEmpty = false);

View file

@ -4,6 +4,7 @@
//
// Created by Clement on 7/21/15.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -65,7 +66,7 @@ private:
const microseconds SendQueue::MAXIMUM_ESTIMATED_TIMEOUT = seconds(5);
const microseconds SendQueue::MINIMUM_ESTIMATED_TIMEOUT = milliseconds(10);
std::unique_ptr<SendQueue> SendQueue::create(Socket* socket, HifiSockAddr destination, SequenceNumber currentSequenceNumber,
std::unique_ptr<SendQueue> SendQueue::create(Socket* socket, SockAddr destination, SequenceNumber currentSequenceNumber,
MessageNumber currentMessageNumber, bool hasReceivedHandshakeACK) {
Q_ASSERT_X(socket, "SendQueue::create", "Must be called with a valid Socket*");
@ -91,7 +92,7 @@ std::unique_ptr<SendQueue> SendQueue::create(Socket* socket, HifiSockAddr destin
return queue;
}
SendQueue::SendQueue(Socket* socket, HifiSockAddr dest, SequenceNumber currentSequenceNumber,
SendQueue::SendQueue(Socket* socket, SockAddr dest, SequenceNumber currentSequenceNumber,
MessageNumber currentMessageNumber, bool hasReceivedHandshakeACK) :
_packets(currentMessageNumber),
_socket(socket),
@ -561,6 +562,6 @@ bool SendQueue::isFlowWindowFull() const {
return seqlen(SequenceNumber { (uint32_t) _lastACKSequenceNumber }, _currentSequenceNumber) > _flowWindowSize;
}
void SendQueue::updateDestinationAddress(HifiSockAddr newAddress) {
void SendQueue::updateDestinationAddress(SockAddr newAddress) {
_destination = newAddress;
}

View file

@ -4,6 +4,7 @@
//
// Created by Clement on 7/21/15.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -25,7 +26,7 @@
#include <PortableHighResolutionClock.h>
#include "../HifiSockAddr.h"
#include "../SockAddr.h"
#include "Constants.h"
#include "PacketQueue.h"
@ -50,7 +51,7 @@ public:
Stopped
};
static std::unique_ptr<SendQueue> create(Socket* socket, HifiSockAddr destination,
static std::unique_ptr<SendQueue> create(Socket* socket, SockAddr destination,
SequenceNumber currentSequenceNumber, MessageNumber currentMessageNumber,
bool hasReceivedHandshakeACK);
@ -75,7 +76,7 @@ public slots:
void ack(SequenceNumber ack);
void fastRetransmit(SequenceNumber ack);
void handshakeACK();
void updateDestinationAddress(HifiSockAddr newAddress);
void updateDestinationAddress(SockAddr newAddress);
signals:
void packetSent(int wireSize, int payloadSize, SequenceNumber seqNum, p_high_resolution_clock::time_point timePoint);
@ -89,7 +90,7 @@ private slots:
void run();
private:
SendQueue(Socket* socket, HifiSockAddr dest, SequenceNumber currentSequenceNumber,
SendQueue(Socket* socket, SockAddr dest, SequenceNumber currentSequenceNumber,
MessageNumber currentMessageNumber, bool hasReceivedHandshakeACK);
SendQueue(SendQueue& other) = delete;
SendQueue(SendQueue&& other) = delete;
@ -113,7 +114,7 @@ private:
PacketQueue _packets;
Socket* _socket { nullptr }; // Socket to send packet on
HifiSockAddr _destination; // Destination addr
SockAddr _destination; // Destination addr
std::atomic<uint32_t> _lastACKSequenceNumber { 0 }; // Last ACKed sequence number

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2015-07-20.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -123,7 +124,7 @@ void Socket::setSystemBufferSizes() {
}
}
qint64 Socket::writeBasePacket(const udt::BasePacket& packet, const HifiSockAddr &sockAddr) {
qint64 Socket::writeBasePacket(const udt::BasePacket& packet, const SockAddr &sockAddr) {
// Since this is a base packet we have no way to know if this is reliable or not - we just fire it off
// this should not be called with an instance of Packet
@ -133,7 +134,7 @@ qint64 Socket::writeBasePacket(const udt::BasePacket& packet, const HifiSockAddr
return writeDatagram(packet.getData(), packet.getDataSize(), sockAddr);
}
qint64 Socket::writePacket(const Packet& packet, const HifiSockAddr& sockAddr) {
qint64 Socket::writePacket(const Packet& packet, const SockAddr& sockAddr) {
Q_ASSERT_X(!packet.isReliable(), "Socket::writePacket", "Cannot send a reliable packet unreliably");
SequenceNumber sequenceNumber;
@ -154,7 +155,7 @@ qint64 Socket::writePacket(const Packet& packet, const HifiSockAddr& sockAddr) {
return writeDatagram(packet.getData(), packet.getDataSize(), sockAddr);
}
qint64 Socket::writePacket(std::unique_ptr<Packet> packet, const HifiSockAddr& sockAddr) {
qint64 Socket::writePacket(std::unique_ptr<Packet> packet, const SockAddr& sockAddr) {
if (packet->isReliable()) {
// hand this packet off to writeReliablePacket
@ -163,7 +164,7 @@ qint64 Socket::writePacket(std::unique_ptr<Packet> packet, const HifiSockAddr& s
if (QThread::currentThread() != thread()) {
QMetaObject::invokeMethod(this, "writeReliablePacket", Qt::QueuedConnection,
Q_ARG(Packet*, packet.release()),
Q_ARG(HifiSockAddr, sockAddr));
Q_ARG(SockAddr, sockAddr));
} else {
writeReliablePacket(packet.release(), sockAddr);
}
@ -174,7 +175,7 @@ qint64 Socket::writePacket(std::unique_ptr<Packet> packet, const HifiSockAddr& s
return writePacket(*packet, sockAddr);
}
qint64 Socket::writePacketList(std::unique_ptr<PacketList> packetList, const HifiSockAddr& sockAddr) {
qint64 Socket::writePacketList(std::unique_ptr<PacketList> packetList, const SockAddr& sockAddr) {
if (packetList->getNumPackets() == 0) {
qCWarning(networking) << "Trying to send packet list with 0 packets, bailing.";
@ -189,7 +190,7 @@ qint64 Socket::writePacketList(std::unique_ptr<PacketList> packetList, const Hif
auto ptr = packetList.release();
QMetaObject::invokeMethod(this, "writeReliablePacketList", Qt::AutoConnection,
Q_ARG(PacketList*, ptr),
Q_ARG(HifiSockAddr, sockAddr));
Q_ARG(SockAddr, sockAddr));
} else {
writeReliablePacketList(packetList.release(), sockAddr);
}
@ -205,7 +206,7 @@ qint64 Socket::writePacketList(std::unique_ptr<PacketList> packetList, const Hif
return totalBytesSent;
}
void Socket::writeReliablePacket(Packet* packet, const HifiSockAddr& sockAddr) {
void Socket::writeReliablePacket(Packet* packet, const SockAddr& sockAddr) {
auto connection = findOrCreateConnection(sockAddr);
if (connection) {
connection->sendReliablePacket(std::unique_ptr<Packet>(packet));
@ -218,7 +219,7 @@ void Socket::writeReliablePacket(Packet* packet, const HifiSockAddr& sockAddr) {
}
void Socket::writeReliablePacketList(PacketList* packetList, const HifiSockAddr& sockAddr) {
void Socket::writeReliablePacketList(PacketList* packetList, const SockAddr& sockAddr) {
auto connection = findOrCreateConnection(sockAddr);
if (connection) {
connection->sendReliablePacketList(std::unique_ptr<PacketList>(packetList));
@ -230,11 +231,11 @@ void Socket::writeReliablePacketList(PacketList* packetList, const HifiSockAddr&
#endif
}
qint64 Socket::writeDatagram(const char* data, qint64 size, const HifiSockAddr& sockAddr) {
qint64 Socket::writeDatagram(const char* data, qint64 size, const SockAddr& sockAddr) {
return writeDatagram(QByteArray::fromRawData(data, size), sockAddr);
}
qint64 Socket::writeDatagram(const QByteArray& datagram, const HifiSockAddr& sockAddr) {
qint64 Socket::writeDatagram(const QByteArray& datagram, const SockAddr& sockAddr) {
// don't attempt to write the datagram if we're unbound. Just drop it.
// _udpSocket.writeDatagram will return an error anyway, but there are
@ -270,7 +271,7 @@ qint64 Socket::writeDatagram(const QByteArray& datagram, const HifiSockAddr& soc
return bytesWritten;
}
Connection* Socket::findOrCreateConnection(const HifiSockAddr& sockAddr, bool filterCreate) {
Connection* Socket::findOrCreateConnection(const SockAddr& sockAddr, bool filterCreate) {
Lock connectionsLock(_connectionsHashMutex);
auto it = _connectionsHash.find(sockAddr);
@ -319,7 +320,7 @@ void Socket::clearConnections() {
}
}
void Socket::cleanupConnection(HifiSockAddr sockAddr) {
void Socket::cleanupConnection(SockAddr sockAddr) {
Lock connectionsLock(_connectionsHashMutex);
auto numErased = _connectionsHash.erase(sockAddr);
@ -390,8 +391,8 @@ void Socket::readPendingDatagrams() {
// grab a time point we can mark as the receive time of this packet
auto receiveTime = p_high_resolution_clock::now();
// setup a HifiSockAddr to read into
HifiSockAddr senderSockAddr;
// setup a SockAddr to read into
SockAddr senderSockAddr;
// setup a buffer to read the packet into
auto buffer = std::unique_ptr<char[]>(new char[packetSizeWithHeader]);
@ -413,7 +414,7 @@ void Socket::readPendingDatagrams() {
auto it = _unfilteredHandlers.find(senderSockAddr);
if (it != _unfilteredHandlers.end()) {
// we have a registered unfiltered handler for this HifiSockAddr - call that and return
// we have a registered unfiltered handler for this SockAddr - call that and return
if (it->second) {
auto basePacket = BasePacket::fromReceivedPacket(std::move(buffer), packetSizeWithHeader, senderSockAddr);
basePacket->setReceiveTime(receiveTime);
@ -482,7 +483,7 @@ void Socket::readPendingDatagrams() {
}
}
void Socket::connectToSendSignal(const HifiSockAddr& destinationAddr, QObject* receiver, const char* slot) {
void Socket::connectToSendSignal(const SockAddr& destinationAddr, QObject* receiver, const char* slot) {
Lock connectionsLock(_connectionsHashMutex);
auto it = _connectionsHash.find(destinationAddr);
if (it != _connectionsHash.end()) {
@ -507,7 +508,7 @@ void Socket::setConnectionMaxBandwidth(int maxBandwidth) {
}
}
ConnectionStats::Stats Socket::sampleStatsForConnection(const HifiSockAddr& destination) {
ConnectionStats::Stats Socket::sampleStatsForConnection(const SockAddr& destination) {
auto it = _connectionsHash.find(destination);
if (it != _connectionsHash.end()) {
return it->second->sampleStats();
@ -528,8 +529,8 @@ Socket::StatsVector Socket::sampleStatsForAllConnections() {
}
std::vector<HifiSockAddr> Socket::getConnectionSockAddrs() {
std::vector<HifiSockAddr> addr;
std::vector<SockAddr> Socket::getConnectionSockAddrs() {
std::vector<SockAddr> addr;
Lock connectionsLock(_connectionsHashMutex);
addr.reserve(_connectionsHash.size());
@ -569,7 +570,7 @@ void Socket::handleStateChanged(QAbstractSocket::SocketState socketState) {
}
}
void Socket::handleRemoteAddressChange(HifiSockAddr previousAddress, HifiSockAddr currentAddress) {
void Socket::handleRemoteAddressChange(SockAddr previousAddress, SockAddr currentAddress) {
{
Lock connectionsLock(_connectionsHashMutex);
@ -597,7 +598,7 @@ void Socket::handleRemoteAddressChange(HifiSockAddr previousAddress, HifiSockAdd
#if (PR_BUILD || DEV_BUILD)
void Socket::sendFakedHandshakeRequest(const HifiSockAddr& sockAddr) {
void Socket::sendFakedHandshakeRequest(const SockAddr& sockAddr) {
auto connection = findOrCreateConnection(sockAddr);
if (connection) {
connection->sendHandshakeRequest();

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2015-07-20.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -23,7 +24,7 @@
#include <QtCore/QTimer>
#include <QtNetwork/QUdpSocket>
#include "../HifiSockAddr.h"
#include "../SockAddr.h"
#include "TCPVegasCC.h"
#include "Connection.h"
@ -39,12 +40,12 @@ class PacketList;
class SequenceNumber;
using PacketFilterOperator = std::function<bool(const Packet&)>;
using ConnectionCreationFilterOperator = std::function<bool(const HifiSockAddr&)>;
using ConnectionCreationFilterOperator = std::function<bool(const SockAddr&)>;
using BasePacketHandler = std::function<void(std::unique_ptr<BasePacket>)>;
using PacketHandler = std::function<void(std::unique_ptr<Packet>)>;
using MessageHandler = std::function<void(std::unique_ptr<Packet>)>;
using MessageFailureHandler = std::function<void(HifiSockAddr, udt::Packet::MessageNumber)>;
using MessageFailureHandler = std::function<void(SockAddr, udt::Packet::MessageNumber)>;
class Socket : public QObject {
Q_OBJECT
@ -53,19 +54,19 @@ class Socket : public QObject {
using Lock = std::unique_lock<Mutex>;
public:
using StatsVector = std::vector<std::pair<HifiSockAddr, ConnectionStats::Stats>>;
using StatsVector = std::vector<std::pair<SockAddr, ConnectionStats::Stats>>;
Socket(QObject* object = 0, bool shouldChangeSocketOptions = true);
quint16 localPort() const { return _udpSocket.localPort(); }
// Simple functions writing to the socket with no processing
qint64 writeBasePacket(const BasePacket& packet, const HifiSockAddr& sockAddr);
qint64 writePacket(const Packet& packet, const HifiSockAddr& sockAddr);
qint64 writePacket(std::unique_ptr<Packet> packet, const HifiSockAddr& sockAddr);
qint64 writePacketList(std::unique_ptr<PacketList> packetList, const HifiSockAddr& sockAddr);
qint64 writeDatagram(const char* data, qint64 size, const HifiSockAddr& sockAddr);
qint64 writeDatagram(const QByteArray& datagram, const HifiSockAddr& sockAddr);
qint64 writeBasePacket(const BasePacket& packet, const SockAddr& sockAddr);
qint64 writePacket(const Packet& packet, const SockAddr& sockAddr);
qint64 writePacket(std::unique_ptr<Packet> packet, const SockAddr& sockAddr);
qint64 writePacketList(std::unique_ptr<PacketList> packetList, const SockAddr& sockAddr);
qint64 writeDatagram(const char* data, qint64 size, const SockAddr& sockAddr);
qint64 writeDatagram(const QByteArray& datagram, const SockAddr& sockAddr);
void bind(const QHostAddress& address, quint16 port = 0);
void rebind(quint16 port);
@ -78,7 +79,7 @@ public:
void setConnectionCreationFilterOperator(ConnectionCreationFilterOperator filterOperator)
{ _connectionCreationFilterOperator = filterOperator; }
void addUnfilteredHandler(const HifiSockAddr& senderSockAddr, BasePacketHandler handler)
void addUnfilteredHandler(const SockAddr& senderSockAddr, BasePacketHandler handler)
{ _unfilteredHandlers[senderSockAddr] = handler; }
void setCongestionControlFactory(std::unique_ptr<CongestionControlVirtualFactory> ccFactory);
@ -90,16 +91,16 @@ public:
StatsVector sampleStatsForAllConnections();
#if (PR_BUILD || DEV_BUILD)
void sendFakedHandshakeRequest(const HifiSockAddr& sockAddr);
void sendFakedHandshakeRequest(const SockAddr& sockAddr);
#endif
signals:
void clientHandshakeRequestComplete(const HifiSockAddr& sockAddr);
void clientHandshakeRequestComplete(const SockAddr& sockAddr);
public slots:
void cleanupConnection(HifiSockAddr sockAddr);
void cleanupConnection(SockAddr sockAddr);
void clearConnections();
void handleRemoteAddressChange(HifiSockAddr previousAddress, HifiSockAddr currentAddress);
void handleRemoteAddressChange(SockAddr previousAddress, SockAddr currentAddress);
private slots:
void readPendingDatagrams();
@ -110,16 +111,16 @@ private slots:
private:
void setSystemBufferSizes();
Connection* findOrCreateConnection(const HifiSockAddr& sockAddr, bool filterCreation = false);
Connection* findOrCreateConnection(const SockAddr& sockAddr, bool filterCreation = false);
// privatized methods used by UDTTest - they are private since they must be called on the Socket thread
ConnectionStats::Stats sampleStatsForConnection(const HifiSockAddr& destination);
ConnectionStats::Stats sampleStatsForConnection(const SockAddr& destination);
std::vector<HifiSockAddr> getConnectionSockAddrs();
void connectToSendSignal(const HifiSockAddr& destinationAddr, QObject* receiver, const char* slot);
std::vector<SockAddr> getConnectionSockAddrs();
void connectToSendSignal(const SockAddr& destinationAddr, QObject* receiver, const char* slot);
Q_INVOKABLE void writeReliablePacket(Packet* packet, const HifiSockAddr& sockAddr);
Q_INVOKABLE void writeReliablePacketList(PacketList* packetList, const HifiSockAddr& sockAddr);
Q_INVOKABLE void writeReliablePacket(Packet* packet, const SockAddr& sockAddr);
Q_INVOKABLE void writeReliablePacketList(PacketList* packetList, const SockAddr& sockAddr);
QUdpSocket _udpSocket { this };
PacketFilterOperator _packetFilterOperator;
@ -131,9 +132,9 @@ private:
Mutex _unreliableSequenceNumbersMutex;
Mutex _connectionsHashMutex;
std::unordered_map<HifiSockAddr, BasePacketHandler> _unfilteredHandlers;
std::unordered_map<HifiSockAddr, SequenceNumber> _unreliableSequenceNumbers;
std::unordered_map<HifiSockAddr, std::unique_ptr<Connection>> _connectionsHash;
std::unordered_map<SockAddr, BasePacketHandler> _unfilteredHandlers;
std::unordered_map<SockAddr, SequenceNumber> _unreliableSequenceNumbers;
std::unordered_map<SockAddr, std::unique_ptr<Connection>> _connectionsHash;
QTimer* _readyReadBackupTimer { nullptr };
@ -145,7 +146,7 @@ private:
int _lastPacketSizeRead { 0 };
SequenceNumber _lastReceivedSequenceNumber;
HifiSockAddr _lastPacketSockAddr;
SockAddr _lastPacketSockAddr;
friend UDTTest;
};

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 07/14/15.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -20,7 +21,7 @@ std::unique_ptr<NLPacket> copyToReadPacket(std::unique_ptr<NLPacket>& packet) {
auto size = packet->getDataSize();
auto data = std::unique_ptr<char[]>(new char[size]);
memcpy(data.get(), packet->getData(), size);
return NLPacket::fromReceivedPacket(std::move(data), size, HifiSockAddr());
return NLPacket::fromReceivedPacket(std::move(data), size, SockAddr());
}
void PacketTests::emptyPacketTest() {

View file

@ -4,6 +4,7 @@
//
// Created by Seth Alves on 3/5/15.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -62,7 +63,7 @@ ICEClientApp::ICEClientApp(int argc, char* argv[]) :
const_cast<QLoggingCategory*>(&networking())->setEnabled(QtWarningMsg, false);
}
_stunSockAddr = HifiSockAddr(STUN_SERVER_HOSTNAME, STUN_SERVER_PORT, true);
_stunSockAddr = SockAddr(STUN_SERVER_HOSTNAME, STUN_SERVER_PORT, true);
_cacheSTUNResult = parser.isSet(cacheSTUNOption);
@ -79,7 +80,7 @@ ICEClientApp::ICEClientApp(int argc, char* argv[]) :
}
}
_iceServerAddr = HifiSockAddr("127.0.0.1", ICE_SERVER_DEFAULT_PORT);
_iceServerAddr = SockAddr("127.0.0.1", ICE_SERVER_DEFAULT_PORT);
if (parser.isSet(iceServerAddressOption)) {
// parse the IP and port combination for this target
QString hostnamePortString = parser.value(iceServerAddressOption);
@ -96,7 +97,7 @@ ICEClientApp::ICEClientApp(int argc, char* argv[]) :
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
} else {
_iceServerAddr = HifiSockAddr(address, port);
_iceServerAddr = SockAddr(address, port);
}
}
@ -142,8 +143,8 @@ void ICEClientApp::openSocket() {
if (_verbose) {
qDebug() << "local port is" << _socket->localPort();
}
_localSockAddr = HifiSockAddr("127.0.0.1", _socket->localPort());
_publicSockAddr = HifiSockAddr("127.0.0.1", _socket->localPort());
_localSockAddr = SockAddr("127.0.0.1", _socket->localPort());
_publicSockAddr = SockAddr("127.0.0.1", _socket->localPort());
_domainPingCount = 0;
}
@ -238,7 +239,7 @@ void ICEClientApp::stunResponseTimeout() {
QCoreApplication::exit(stunFailureExitStatus);
}
void ICEClientApp::sendPacketToIceServer(PacketType packetType, const HifiSockAddr& iceServerSockAddr,
void ICEClientApp::sendPacketToIceServer(PacketType packetType, const SockAddr& iceServerSockAddr,
const QUuid& clientID, const QUuid& peerID) {
std::unique_ptr<NLPacket> icePacket = NLPacket::create(packetType);
@ -303,7 +304,7 @@ void ICEClientApp::processSTUNResponse(std::unique_ptr<udt::BasePacket> packet)
uint16_t newPublicPort;
QHostAddress newPublicAddress;
if (LimitedNodeList::parseSTUNResponse(packet.get(), newPublicAddress, newPublicPort)) {
_publicSockAddr = HifiSockAddr(newPublicAddress, newPublicPort);
_publicSockAddr = SockAddr(newPublicAddress, newPublicPort);
if (_verbose) {
qDebug() << "My public address is" << _publicSockAddr;
}
@ -326,7 +327,7 @@ void ICEClientApp::processPacket(std::unique_ptr<udt::Packet> packet) {
}
QSharedPointer<ReceivedMessage> message = QSharedPointer<ReceivedMessage>::create(*nlPacket);
const HifiSockAddr& senderAddr = message->getSenderSockAddr();
const SockAddr& senderAddr = message->getSenderSockAddr();
if (nlPacket->getType() == PacketType::ICEServerPeerInformation) {
// cancel the timeout timer

View file

@ -4,6 +4,7 @@
//
// Created by Seth Alves on 2016-9-16
// Copyright 2016 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -54,7 +55,7 @@ private:
void setState(int newState);
void doSomething();
void sendPacketToIceServer(PacketType packetType, const HifiSockAddr& iceServerSockAddr,
void sendPacketToIceServer(PacketType packetType, const SockAddr& iceServerSockAddr,
const QUuid& clientID, const QUuid& peerID);
void icePingDomainServer();
void processSTUNResponse(std::unique_ptr<udt::BasePacket> packet);
@ -65,7 +66,7 @@ private:
bool _cacheSTUNResult; // should we only talk to stun server once?
bool _stunResultSet { false }; // have we already talked to stun server?
HifiSockAddr _stunSockAddr;
SockAddr _stunSockAddr;
unsigned int _actionCount { 0 };
unsigned int _actionMax { 0 };
@ -75,10 +76,10 @@ private:
QTimer* _pingDomainTimer { nullptr };
HifiSockAddr _iceServerAddr;
SockAddr _iceServerAddr;
HifiSockAddr _localSockAddr;
HifiSockAddr _publicSockAddr;
SockAddr _localSockAddr;
SockAddr _publicSockAddr;
udt::Socket* _socket { nullptr };
bool _domainServerPeerSet { false };

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2015-07-30.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -90,7 +91,7 @@ UDTTest::UDTTest(int& argc, char** argv) :
QMetaObject::invokeMethod(this, "quit", Qt::QueuedConnection);
} else {
_target = HifiSockAddr(address, port);
_target = SockAddr(address, port);
qDebug() << "Packets will be sent to" << _target;
}
}
@ -198,7 +199,7 @@ UDTTest::UDTTest(int& argc, char** argv) :
});
}
_socket.setMessageFailureHandler(
[this](HifiSockAddr from, udt::Packet::MessageNumber messageNumber) {
[this](SockAddr from, udt::Packet::MessageNumber messageNumber) {
_pendingMessages.erase(messageNumber);
}
);

View file

@ -4,6 +4,7 @@
//
// Created by Stephen Birarda on 2015-07-30.
// Copyright 2015 High Fidelity, Inc.
// Copyright 2021 Vircadia contributors.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
@ -49,7 +50,7 @@ private:
QCommandLineParser _argumentParser;
udt::Socket _socket;
HifiSockAddr _target; // the target for sent packets
SockAddr _target; // the target for sent packets
int _minPacketSize { udt::MAX_PACKET_SIZE };
int _maxPacketSize { udt::MAX_PACKET_SIZE };