update port length to 2 bytes

PiperOrigin-RevId: 526722524
This commit is contained in:
Anay Wadhera
2023-04-24 12:28:06 -07:00
committed by Copybara-Service
parent b68f5324ff
commit 70bcabb161
3 changed files with 9 additions and 6 deletions
+1 -1
View File
@@ -36,7 +36,7 @@ constexpr char kAction = 0x0F;
constexpr absl::string_view kBluetoothUuid{"test"};
// WLAN
constexpr absl::string_view kIpv4Addr = "\x4C\x8B\x1D\xCE";
constexpr absl::string_view kPort = "\x12\x34\x56\x78";
constexpr absl::string_view kPort = "\x12\x34";
constexpr absl::string_view kBssid = "\x0A\x1B\x2C\x34\x58\x7E";
TEST(ConnectionInfoTest, TestRestoreBle) {
+7 -4
View File
@@ -25,10 +25,10 @@
namespace nearby {
constexpr int kIpv4AddressLength = 4;
constexpr int kIpv6AddressLength = 16;
constexpr int kPortLength = 4;
constexpr int kBssidLength = 6;
inline constexpr int kIpv4AddressLength = 4;
inline constexpr int kIpv6AddressLength = 16;
inline constexpr int kPortLength = 2;
inline constexpr int kBssidLength = 6;
class WifiLanConnectionInfo : public ConnectionInfo {
public:
@@ -51,6 +51,9 @@ class WifiLanConnectionInfo : public ConnectionInfo {
}
std::string ToDataElementBytes() const override;
std::string GetIpAddress() const { return ip_address_; }
// This port is expected to be in hex form, such as \xFF\xFF for a value of
// 65535, 2 bytes in length. This field will be represented in network byte
// order (aka big-endian), so \x12\x34 will correspond to port 4660 (0x1234).
std::string GetPort() const { return port_; }
std::string GetBssid() const { return bssid_; }
char GetActions() const override { return actions_; }
@@ -30,7 +30,7 @@ namespace {
constexpr absl::string_view kIpv4Addr = "\x4C\x8B\x1D\xCE";
constexpr absl::string_view kIpv6Addr =
"\x4C\x8B\x1D\xCE\x4C\x8B\x1D\xCE\x4C\x8B\x1D\xCE\x4C\x8B\x1D\xCE";
constexpr absl::string_view kPort = "\x12\x34\x56\x78";
constexpr absl::string_view kPort = "\x12\x34";
constexpr absl::string_view kBssid = "\x0A\x1B\x2C\x34\x58\x7E";
constexpr char kAction = 0x0F;