Skip to content

Commit

Permalink
Remove SB_HAS_IPV6 config (#4109)
Browse files Browse the repository at this point in the history
Last platform that didn't support it has been removed.
SbSocketIsIpv6Supported should be deprecated as follow-up.

b/366061817
  • Loading branch information
kaidokert authored Sep 17, 2024
1 parent 6438fd0 commit 948d0bf
Show file tree
Hide file tree
Showing 41 changed files with 2 additions and 329 deletions.
12 changes: 0 additions & 12 deletions cobalt/csp/source_list_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,6 @@ TEST_F(SourceListTest, TestInsecureLocalhostDefaultInsecureV4) {
EXPECT_FALSE(source_list.Matches(GURL("https://example.locaLHost./")));
}

#if SB_HAS(IPV6)
TEST_F(SourceListTest, TestInsecureLocalhostDefaultInsecureV6) {
SourceList source_list(&checker_, csp_.get(), "connect-src");

Expand Down Expand Up @@ -259,7 +258,6 @@ TEST_F(SourceListTest, TestInsecureLocalhostDefaultInsecureV6) {
EXPECT_FALSE(source_list.Matches(
GURL("https://[0000:0000:0000:0000:0000:0000:0000:0001]:80/")));
}
#endif

TEST_F(SourceListTest, TestInsecureLocalhostInsecureV4) {
SourceList source_list(&checker_, csp_.get(), "connect-src");
Expand All @@ -279,7 +277,6 @@ TEST_F(SourceListTest, TestInsecureLocalhostInsecureV4) {
EXPECT_TRUE(source_list.Matches(GURL("http://127.255.0.0/")));
}

#if SB_HAS(IPV6)
TEST_F(SourceListTest, TestInsecureLocalhostInsecureV6) {
SourceList source_list(&checker_, csp_.get(), "connect-src");
std::string sources = "'cobalt-insecure-localhost'";
Expand All @@ -295,7 +292,6 @@ TEST_F(SourceListTest, TestInsecureLocalhostInsecureV6) {
EXPECT_TRUE(source_list.Matches(
GURL("http://[0000:0000:0000:0000:0000:0000:0000:0001]:80/")));
}
#endif

TEST_F(SourceListTest, TestInsecureLocalhostSecureV4) {
SourceList source_list(&checker_, csp_.get(), "connect-src");
Expand Down Expand Up @@ -327,7 +323,6 @@ TEST_F(SourceListTest, TestInsecureLocalhostSecureV4) {
EXPECT_FALSE(source_list.Matches(GURL("https://example.locaLHost./")));
}

#if SB_HAS(IPV6)
TEST_F(SourceListTest, TestInsecureLocalhostSecureV6) {
SourceList source_list(&checker_, csp_.get(), "connect-src");
std::string sources = "'cobalt-insecure-localhost'";
Expand All @@ -349,7 +344,6 @@ TEST_F(SourceListTest, TestInsecureLocalhostSecureV6) {
EXPECT_FALSE(source_list.Matches(
GURL("https://[0000:0000:0000:0000:0000:0000:0000:0001]:80/")));
}
#endif

TEST_F(SourceListTest, TestInsecurePrivateRangeDefaultV4) {
SourceList source_list(&checker_, csp_.get(), "connect-src");
Expand All @@ -367,7 +361,6 @@ TEST_F(SourceListTest, TestInsecurePrivateRangeDefaultV4) {
EXPECT_FALSE(source_list.Matches(GURL("https://255.255.255.255/")));
}

#if SB_HAS(IPV6)
TEST_F(SourceListTest, TestInsecurePrivateRangeDefaultV6) {
SourceList source_list(&checker_, csp_.get(), "connect-src");

Expand All @@ -382,7 +375,6 @@ TEST_F(SourceListTest, TestInsecurePrivateRangeDefaultV6) {
EXPECT_FALSE(source_list.Matches(GURL("http://[FE80::]/")));
EXPECT_FALSE(source_list.Matches(GURL("https://[FE80::]/")));
}
#endif

TEST_F(SourceListTest, TestInsecurePrivateRangeV4Private) {
std::string sources = "'cobalt-insecure-private-range'";
Expand Down Expand Up @@ -416,7 +408,6 @@ TEST_F(SourceListTest, TestInsecurePrivateRangeV4Secure) {
EXPECT_FALSE(source_list.Matches(GURL("https://0.0.0.0/")));
}

#if SB_HAS(IPV6)
TEST_F(SourceListTest, TestInsecurePrivateRangeV6ULA) {
std::string sources = "'cobalt-insecure-private-range'";
// These are insecure calls.
Expand Down Expand Up @@ -446,7 +437,6 @@ TEST_F(SourceListTest, TestInsecurePrivateRangeV6Secure) {
GURL("https://[2606:2800:220:1:248:1893:25c8:1946]/")));
EXPECT_FALSE(source_list.Matches(GURL("https://[FE80::]/")));
}
#endif

TEST_F(SourceListTest, TestInsecureLocalNetworkDefaultV4Local) {
std::string sources = "'cobalt-insecure-local-network'";
Expand Down Expand Up @@ -481,7 +471,6 @@ TEST_F(SourceListTest, TestInsecureLocalNetworkDefaultV4Secure) {
EXPECT_FALSE(source_list.Matches(GURL("https://143.195.170.1/")));
}

#if SB_HAS(IPV6)
TEST_F(SourceListTest, TestInsecureLocalNetworkDefaultV6Local) {
std::string sources = "'cobalt-insecure-local-network'";
SourceList source_list(&checker_, csp_.get(), "connect-src");
Expand Down Expand Up @@ -520,7 +509,6 @@ TEST_F(SourceListTest, TestInsecureLocalNetworkDefaultV6Secure) {
EXPECT_FALSE(source_list.Matches(
GURL("https://[2606:2800:220:1:248:1893:25c8:1946]/")));
}
#endif

TEST_F(SourceListTest, TestInvalidHash) {
std::string sources = "'sha256-c3uoUQo23pT8hqB5MoAZnI9LiPUc+lWgGBKHfV07iAM='";
Expand Down
4 changes: 0 additions & 4 deletions cobalt/network/local_network_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ TEST(IsPrivateRange, v4) {
EXPECT_FALSE(IsIPInPrivateRange(ParseSocketAddress("239.255.255.255")));
}

#if SB_HAS(IPV6)

TEST(IsPrivateRange, v6) {
EXPECT_TRUE(IsIPInPrivateRange(ParseSocketAddress("[fd00::]")));
EXPECT_TRUE(IsIPInPrivateRange(ParseSocketAddress("[fd00:1:2:3:4:5::]")));
Expand All @@ -53,7 +51,5 @@ TEST(IsPrivateRange, v6) {
ParseSocketAddress("[2606:2800:220:1:248:1893:25c8:1946]")));
}

#endif // SB_HAS(IPV6)

} // namespace network
} // namespace cobalt
8 changes: 0 additions & 8 deletions cobalt/site/docs/reference/starboard/configuration-public.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ Book: /youtube/cobalt/_book.yaml
| :--- |
| **`SB_HAS_QUIRK_SUPPORT_INT16_AUDIO_SAMPLES`**<br><br>The implementation is allowed to support kSbMediaAudioSampleTypeInt16 only when this macro is defined.<br><br>By default, this property is undefined. |


## Network Configuration

| Properties |
| :--- |
| **`SB_HAS_IPV6`**<br><br>Specifies whether this platform supports IPV6.<br><br>The default value in the Stub implementation is `1` |


## System Header Configuration

Any system headers listed here that are not provided by the platform will be emulated in starboard/types.h.
Expand Down
2 changes: 0 additions & 2 deletions net/socket/tcp_socket_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,6 @@ TEST_F(TCPSocketTest, Accept2Connections) {
EXPECT_EQ(accepted_address2.address(), local_address_.address());
}

#if !defined(STARBOARD) || SB_HAS(IPV6)
// Test listening and accepting with a socket bound to an IPv6 address.
TEST_F(TCPSocketTest, AcceptIPv6) {
bool initialized = false;
Expand All @@ -398,7 +397,6 @@ TEST_F(TCPSocketTest, AcceptIPv6) {

EXPECT_THAT(connect_callback.GetResult(connect_result), IsOk());
}
#endif

TEST_F(TCPSocketTest, ReadWrite) {
ASSERT_NO_FATAL_FAILURE(SetUpListenIPv4());
Expand Down
5 changes: 0 additions & 5 deletions starboard/android/shared/configuration_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,4 @@
#define SB_IS_WCHAR_T_UNSIGNED 1
#endif

// --- Network Configuration -------------------------------------------------

// Specifies whether this platform supports IPV6.
#define SB_HAS_IPV6 1

#endif // STARBOARD_ANDROID_SHARED_CONFIGURATION_PUBLIC_H_
5 changes: 0 additions & 5 deletions starboard/evergreen/arm/hardfp/configuration_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,4 @@
#define SB_IS_WCHAR_T_UNSIGNED 1
#endif

// --- Network Configuration -------------------------------------------------

// Specifies whether this platform supports IPV6.
#define SB_HAS_IPV6 1

#endif // STARBOARD_EVERGREEN_ARM_HARDFP_CONFIGURATION_PUBLIC_H_
5 changes: 0 additions & 5 deletions starboard/evergreen/arm/softfp/configuration_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,4 @@
#define SB_IS_WCHAR_T_UNSIGNED 1
#endif

// --- Network Configuration -------------------------------------------------

// Specifies whether this platform supports IPV6.
#define SB_HAS_IPV6 1

#endif // STARBOARD_EVERGREEN_ARM_SOFTFP_CONFIGURATION_PUBLIC_H_
5 changes: 0 additions & 5 deletions starboard/evergreen/arm64/configuration_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,4 @@
#define SB_IS_WCHAR_T_UNSIGNED 1
#endif

// --- Network Configuration -------------------------------------------------

// Specifies whether this platform supports IPV6.
#define SB_HAS_IPV6 1

#endif // STARBOARD_EVERGREEN_ARM64_CONFIGURATION_PUBLIC_H_
5 changes: 0 additions & 5 deletions starboard/evergreen/x64/configuration_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,4 @@
#define SB_IS_WCHAR_T_UNSIGNED 1
#endif

// --- Network Configuration -------------------------------------------------

// Specifies whether this platform supports IPV6.
#define SB_HAS_IPV6 1

#endif // STARBOARD_EVERGREEN_X64_CONFIGURATION_PUBLIC_H_
5 changes: 0 additions & 5 deletions starboard/linux/shared/configuration_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@
#define SB_IS_WCHAR_T_UNSIGNED 1
#endif

// --- Network Configuration -------------------------------------------------

// Specifies whether this platform supports IPV6.
#define SB_HAS_IPV6 1

// --- Media Configuration ---------------------------------------------------

// The path of video_dmp_writer.h. Defined here to avoid errors building on
Expand Down
14 changes: 0 additions & 14 deletions starboard/nplb/posix_compliance/posix_socket_accept_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,11 @@ TEST(PosixSocketAcceptTest, RainyDayNoConnection) {
}

// bind socket with local address
#if SB_HAS(IPV6)
sockaddr_in6 address = {};
EXPECT_TRUE(
PosixGetLocalAddressIPv4(reinterpret_cast<sockaddr*>(&address)) == 0 ||
PosixGetLocalAddressIPv6(reinterpret_cast<sockaddr*>(&address)) == 0);
address.sin6_port = htons(GetPortNumberForTests());
#else
sockaddr address = {0};
EXPECT_TRUE(PosixGetLocalAddressIPv4(&address) == 0);
sockaddr_in* address_ptr = reinterpret_cast<sockaddr_in*>(&address);
address_ptr->sin_port = htons(GetPortNumberForTests());
#endif

result = bind(socket_listen_fd, reinterpret_cast<sockaddr*>(&address),
sizeof(sockaddr));
Expand Down Expand Up @@ -135,18 +128,11 @@ TEST(PosixSocketAcceptTest, RainyDayNotListening) {
}

// bind socket with local address
#if SB_HAS(IPV6)
sockaddr_in6 address = {};
EXPECT_TRUE(
PosixGetLocalAddressIPv4(reinterpret_cast<sockaddr*>(&address)) == 0 ||
PosixGetLocalAddressIPv6(reinterpret_cast<sockaddr*>(&address)) == 0);
address.sin6_port = htons(GetPortNumberForTests());
#else
sockaddr address = {0};
EXPECT_TRUE(PosixGetLocalAddressIPv4(&address) == 0);
sockaddr_in* address_ptr = reinterpret_cast<sockaddr_in*>(&address);
address_ptr->sin_port = htons(GetPortNumberForTests());
#endif
EXPECT_TRUE(result == 0);
if (result != 0) {
close(socket_fd);
Expand Down
20 changes: 0 additions & 20 deletions starboard/nplb/posix_compliance/posix_socket_bind_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ TEST(PosixSocketBindTest, RainyDayNullNull) {
EXPECT_FALSE(bind(invalid_socket_fd, NULL, 0) == 0);
}

#if SB_HAS(IPV6)
TEST(PosixSocketBindTest, RainyDayWrongAddressType) {
int socket_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
ASSERT_TRUE(socket_fd > 0);
Expand All @@ -65,7 +64,6 @@ TEST(PosixSocketBindTest, RainyDayWrongAddressType) {
sizeof(sockaddr_in)) == 0);
EXPECT_TRUE(close(socket_fd) == 0);
}
#endif

TEST(PosixSocketBindTest, RainyDayBadInterface) {
int socket_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
Expand All @@ -82,18 +80,11 @@ TEST(PosixSocketBindTest, RainyDayBadInterface) {
}

TEST(PosixSocketBindTest, SunnyDayLocalInterface) {
#if SB_HAS(IPV6)
sockaddr_in6 address = {};
EXPECT_TRUE(
PosixGetLocalAddressIPv4(reinterpret_cast<sockaddr*>(&address)) == 0 ||
PosixGetLocalAddressIPv6(reinterpret_cast<sockaddr*>(&address)) == 0);
address.sin6_port = htons(GetPortNumberForTests());
#else
sockaddr address = {0};
EXPECT_TRUE(PosixGetLocalAddressIPv4(&address) == 0);
sockaddr_in* address_ptr = reinterpret_cast<sockaddr_in*>(&address);
address_ptr->sin_port = htons(GetPortNumberForTests());
#endif

int socket_domain = AF_INET;
int socket_type = SOCK_STREAM;
Expand Down Expand Up @@ -138,14 +129,12 @@ class PosixSocketBindPairFilterTest
int GetFilterType() { return GetParam().second; }
};

#if SB_HAS(IPV6)
class PosixSocketBindPairCSTest
: public ::testing::TestWithParam<std::pair<int, int>> {
public:
int GetServerAddressType() { return GetParam().first; }
int GetClientAddressType() { return GetParam().second; }
};
#endif

TEST_P(PosixSocketBindPairFilterTest, RainyDayNullSocketPair) {
sockaddr_in address = {};
Expand Down Expand Up @@ -225,7 +214,6 @@ TEST_P(PosixSocketBindPairFilterTest, RainyDayBadInterfacePair) {
EXPECT_TRUE(close(socket_fd) == 0);
}

#if SB_HAS(IPV6)
TEST_P(PosixSocketBindPairCSTest, RainyDayWrongAddressTypePair) {
return;
int socket_fd = socket(GetServerAddressType(), SOCK_STREAM, IPPROTO_TCP);
Expand All @@ -247,9 +235,7 @@ TEST_P(PosixSocketBindPairCSTest, RainyDayWrongAddressTypePair) {
sizeof(sockaddr_in)) == 0);
EXPECT_TRUE(close(socket_fd) == 0);
}
#endif

#if SB_HAS(IPV6)
INSTANTIATE_TEST_SUITE_P(PosixSocketBindTest,
PosixSocketBindPairFilterTest,
::testing::Values(std::make_pair(AF_INET, AF_INET),
Expand All @@ -260,12 +246,6 @@ INSTANTIATE_TEST_SUITE_P(PosixSocketBindTest,
::testing::Values(std::make_pair(AF_INET, AF_INET6),
std::make_pair(AF_INET6, AF_INET)),
GetPosixSocketAddressTypeFilterPairName);
#else
INSTANTIATE_TEST_SUITE_P(PosixSocketBindTest,
PosixSocketBindPairFilterTest,
::testing::Values(std::make_pair(AF_INET, AF_INET)),
GetPosixSocketAddressTypeFilterPairName);
#endif

} // namespace
} // namespace nplb
Expand Down
5 changes: 0 additions & 5 deletions starboard/nplb/posix_compliance/posix_socket_errno_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,9 @@ TEST(PosixErrnoTest, ConnectUnavailableAddress) {
ASSERT_TRUE(socket_fd > 0);

sockaddr_in6 address = {};
#if SB_HAS(IPV6)
EXPECT_TRUE(
PosixGetLocalAddressIPv4(reinterpret_cast<sockaddr*>(&address)) == 0 ||
PosixGetLocalAddressIPv6(reinterpret_cast<sockaddr*>(&address)) == 0);
#else
EXPECT_TRUE(PosixGetLocalAddressIPv4(reinterpret_cast<sockaddr*>(&address)) ==
0);
#endif

// Attempt to connect to an address where we expect connection to be refused
connect(socket_fd, (struct sockaddr*)&address, sizeof(address));
Expand Down
9 changes: 0 additions & 9 deletions starboard/nplb/posix_compliance/posix_socket_helpers.cc
Original file line number Diff line number Diff line change
Expand Up @@ -45,18 +45,11 @@ int PosixSocketCreateAndConnect(int server_domain,
return -1;
}
// bind socket with local address
#if SB_HAS(IPV6)
sockaddr_in6 address = {};
EXPECT_TRUE(
PosixGetLocalAddressIPv4(reinterpret_cast<sockaddr*>(&address)) == 0 ||
PosixGetLocalAddressIPv6(reinterpret_cast<sockaddr*>(&address)) == 0);
address.sin6_port = htons(GetPortNumberForTests());
#else
sockaddr address = {0};
EXPECT_TRUE(PosixGetLocalAddressIPv4(&address) == 0);
sockaddr_in* address_ptr = reinterpret_cast<sockaddr_in*>(&address);
address_ptr->sin_port = htons(GetPortNumberForTests());
#endif

result = bind(*listen_socket_fd, reinterpret_cast<struct sockaddr*>(&address),
sizeof(struct sockaddr_in));
Expand Down Expand Up @@ -164,7 +157,6 @@ int PosixGetLocalAddressIPv4(sockaddr* address_ptr) {
return result;
}

#if SB_HAS(IPV6)
int PosixGetLocalAddressIPv6(sockaddr* address_ptr) {
int result = -1;
struct ifaddrs* ifaddr;
Expand All @@ -189,7 +181,6 @@ int PosixGetLocalAddressIPv6(sockaddr* address_ptr) {
freeifaddrs(ifaddr);
return result;
}
#endif

bool PosixWriteBySpinning(int socket,
const char* data,
Expand Down
2 changes: 0 additions & 2 deletions starboard/nplb/posix_compliance/posix_socket_helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,7 @@ int PosixSocketCreateAndConnect(int server_domain,
int* server_socket_fd,
int* client_socket_fd);
int PosixGetLocalAddressIPv4(sockaddr* address_ptr);
#if SB_HAS(IPV6)
int PosixGetLocalAddressIPv6(sockaddr* address_ptr);
#endif // SB_HAS(IPV6)

int PosixSocketSetReceiveBufferSize(int socket_fd, int32_t size);
int PosixSocketSetSendBufferSize(int socket_fd, int32_t size);
Expand Down
Loading

0 comments on commit 948d0bf

Please sign in to comment.