mirror of
https://github.com/kidfromjupiter/nearby.git
synced 2026-09-15 07:06:11 -04:00
Add GetDynamicPortRange api for Wifilan medium
PiperOrigin-RevId: 416669312
This commit is contained in:
@@ -144,6 +144,10 @@ class WifiLanMedium {
|
||||
// On error, returns nullptr.
|
||||
virtual std::unique_ptr<WifiLanServerSocket> ListenForService(
|
||||
int port = 0) = 0;
|
||||
|
||||
// Returns the port range as a pair of min and max port.
|
||||
virtual absl::optional<std::pair<std::int32_t, std::int32_t>>
|
||||
GetDynamicPortRange() = 0;
|
||||
};
|
||||
|
||||
} // namespace api
|
||||
|
||||
@@ -233,6 +233,12 @@ class WifiLanMedium : public api::WifiLanMedium {
|
||||
std::unique_ptr<api::WifiLanServerSocket> ListenForService(int port) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
// Returns the port range as a pair of min and max port.
|
||||
absl::optional<std::pair<std::int32_t, std::int32_t>> GetDynamicPortRange()
|
||||
override {
|
||||
return std::make_pair(49152, 65535);
|
||||
}
|
||||
|
||||
private:
|
||||
struct AdvertisingInfo {
|
||||
bool Empty() const { return service_types.empty(); }
|
||||
|
||||
@@ -155,6 +155,10 @@ class WifiLanMedium : public api::WifiLanMedium {
|
||||
std::unique_ptr<api::WifiLanServerSocket> ListenForService(int port) override
|
||||
ABSL_LOCKS_EXCLUDED(mutex_);
|
||||
|
||||
absl::optional<std::pair<std::int32_t, std::int32_t>> GetDynamicPortRange() override {
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
private:
|
||||
struct AdvertisingInfo {
|
||||
bool Empty() const { return services.empty(); }
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
#include "absl/container/flat_hash_map.h"
|
||||
#include "absl/container/flat_hash_set.h"
|
||||
#include "absl/synchronization/mutex.h"
|
||||
#include "absl/types/optional.h"
|
||||
#include "platform/api/wifi_lan.h"
|
||||
#include "platform/base/exception.h"
|
||||
#include "platform/base/input_stream.h"
|
||||
@@ -247,6 +248,11 @@ class WifiLanMedium : public api::WifiLanMedium {
|
||||
// continue.
|
||||
void NotifyDnsServiceUnregistered(DWORD status);
|
||||
|
||||
absl::optional<std::pair<std::int32_t, std::int32_t>> GetDynamicPortRange()
|
||||
override {
|
||||
return absl::nullopt;
|
||||
}
|
||||
|
||||
private:
|
||||
// mDNS text attributes
|
||||
static constexpr std::string_view KEY_ENDPOINT_INFO = "n";
|
||||
|
||||
@@ -187,6 +187,11 @@ class WifiLanMedium {
|
||||
return WifiLanServerSocket(impl_->ListenForService(port));
|
||||
}
|
||||
|
||||
// Returns the port range as a pair of min and max port.
|
||||
absl::optional<std::pair<std::int32_t, std::int32_t>> GetDynamicPortRange() {
|
||||
return impl_->GetDynamicPortRange();
|
||||
}
|
||||
|
||||
bool IsValid() const { return impl_ != nullptr; }
|
||||
|
||||
api::WifiLanMedium& GetImpl() { return *impl_; }
|
||||
|
||||
Reference in New Issue
Block a user