#include "ipcz/node_connector.h"
#include <algorithm>
#include <utility>
#include "ipcz/driver_memory.h"
#include "ipcz/driver_transport.h"
#include "ipcz/ipcz.h"
#include "ipcz/link_side.h"
#include "ipcz/link_type.h"
#include "ipcz/node_link.h"
#include "ipcz/node_link_memory.h"
#include "ipcz/remote_router_link.h"
#include "ipcz/router.h"
#include "ipcz/sublink_id.h"
#include "third_party/abseil-cpp/absl/base/macros.h"
#include "util/log.h"
#include "util/ref_counted.h"
namespace ipcz {
namespace {
class NodeConnectorForBrokerToNonBroker : public NodeConnector { … };
class NodeConnectorForNonBrokerToBroker : public NodeConnector { … };
class NodeConnectorForReferrer : public NodeConnector { … };
class NodeConnectorForReferredNonBroker : public NodeConnector { … };
class NodeConnectorForBrokerReferral : public NodeConnector { … };
class NodeConnectorForBrokerToBroker : public NodeConnector { … };
std::pair<Ref<NodeConnector>, IpczResult> CreateConnector(
Ref<Node> node,
Ref<DriverTransport> transport,
IpczConnectNodeFlags flags,
const std::vector<Ref<Router>>& initial_routers,
Ref<NodeLink> broker_link,
NodeConnector::ConnectCallback callback) { … }
}
IpczResult NodeConnector::ConnectNode(
Ref<Node> node,
Ref<DriverTransport> transport,
IpczConnectNodeFlags flags,
const std::vector<Ref<Router>>& initial_routers,
ConnectCallback callback) { … }
bool NodeConnector::HandleNonBrokerReferral(
Ref<Node> node,
uint64_t referral_id,
uint32_t num_initial_portals,
Ref<NodeLink> referrer,
Ref<DriverTransport> transport_to_referred_node,
DriverMemoryWithMapping link_memory,
DriverMemoryWithMapping client_link_memory) { … }
NodeConnector::NodeConnector(Ref<Node> node,
Ref<DriverTransport> transport,
IpczConnectNodeFlags flags,
std::vector<Ref<Router>> waiting_routers,
ConnectCallback callback)
: … { … }
NodeConnector::~NodeConnector() = default;
void NodeConnector::AcceptConnection(Node::Connection connection,
uint32_t num_remote_portals) { … }
void NodeConnector::RejectConnection() { … }
bool NodeConnector::ActivateTransport() { … }
void NodeConnector::EstablishWaitingRouters(Ref<NodeLink> to_link,
size_t max_valid_portals) { … }
void NodeConnector::OnTransportError() { … }
}