#include <arpa/inet.h>
#include <linux/netlink.h>
#include <netdb.h>
+#include <net/if.h>
#include <netinet/in.h>
#include <sys/mount.h>
#include <sys/socket.h>
const uint16_t UDP_TEST_PORT = 12000;
const uint16_t TCP_TEST_PORT = 12000;
-const std::string REMOTE_TEST_SERVER_ADDRESS = "10.1.0.2";
-const std::string LOCAL_TEST_SERVER_ADDRESS = "127.0.0.1";
+const std::string REMOTE_INTERFACE_ADDRESS = "10.1.0.2";
+const std::string REMOTE_INTERFACE_NAME = "veth1";
+const std::string LOCAL_HOST_TEST_SERVER_ADDRESS = "127.0.0.1";
+const std::string LOCAL_TEST_MCAST_GROUP = "225.0.0.250";
const std::string DNS_TEST_ADDRESS = "www.samsung.com";
+const std::string ANY_INTERFACE = "";
+
+const char TTL_MCAST_RESTRIC_SUBNET = 1;
const int MONITOR_TIMEOUT = 1000; // ms
return "UDPServer port: " + std::to_string(m_port);
}
+ virtual bool applyExtraSocketOptions(int)
+ {
+ return true;
+ }
+
virtual int serverProcedure(int pipeFd) override
{
FdUniquePtr pipePtr(&pipeFd);
exit(EXIT_FAILURE);
}
+ if (!applyExtraSocketOptions(sockFd)) {
+ exit(EXIT_FAILURE);
+ }
+
struct sockaddr_in clntAddress;
size_t clntAddressLength = sizeof(clntAddress);
char receiveBuffer[NET_BUFFER_SIZE];
AppContext m_appContext;
};
+class UDPMulticastServer : public UDPServer
+{
+public:
+ UDPMulticastServer(uint16_t port, int protocol,
+ const std::string &mcastGroup, const std::string &networkInterface)
+ : UDPServer(port, protocol)
+ , m_mcastGroup(mcastGroup)
+ , m_networkInterface(networkInterface)
+ {
+ }
+
+ bool applyExtraSocketOptions(int sockFd) override
+ {
+ struct ip_mreq multicastRequest;
+ memset(&multicastRequest, 0, sizeof(multicastRequest));
+
+ in_addr_t mcastGroupAddr = inet_addr(m_mcastGroup.c_str());
+ if (!IN_MULTICAST(mcastGroupAddr)) {
+ return false;
+ }
+
+ multicastRequest.imr_multiaddr.s_addr = mcastGroupAddr;
+
+ if (m_networkInterface == ANY_INTERFACE) {
+ multicastRequest.imr_interface.s_addr = INADDR_ANY;
+ } else {
+ struct ifreq interfaceRequest;
+ memset(&interfaceRequest, 0, sizeof(interfaceRequest));
+
+ interfaceRequest.ifr_addr.sa_family = AF_INET;
+ strncpy(interfaceRequest.ifr_name, m_networkInterface.c_str(), IFNAMSIZ);
+ interfaceRequest.ifr_name[IFNAMSIZ - 1] = '\0';
+
+ if (ioctl(sockFd, SIOCGIFADDR, &interfaceRequest) == -1) {
+ return false;
+ }
+
+ struct sockaddr_in *addr = reinterpret_cast<struct sockaddr_in *>(&interfaceRequest.ifr_addr);
+ multicastRequest.imr_interface.s_addr = addr->sin_addr.s_addr;
+ }
+
+ return setsockopt(sockFd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
+ static_cast<const void *>(&multicastRequest), sizeof(multicastRequest)) == 0;
+ }
+
+private:
+ std::string m_mcastGroup;
+ std::string m_networkInterface;
+};
+
+
+class UDPMulticastServerApp : public UDPMulticastServer
+{
+public:
+ UDPMulticastServerApp(uint16_t port, int protocol, const std::string &mcastGroup, const std::string &networkInterface,
+ const AppContext &appContext)
+ : UDPMulticastServer(port, protocol, mcastGroup, networkInterface)
+ , m_appContext(appContext)
+ {
+ }
+
+ virtual int serverProcedure(int pipeFd) override
+ {
+ Api::setProcessLabel(m_appContext.appId());
+ RUNNER_ASSERT_ERRNO_MSG(drop_root_privileges(m_appContext.getUID(), m_appContext.getGID()) == 0,
+ "drop_root_privileges() failed");
+
+ return UDPServer::serverProcedure(pipeFd);
+ }
+
+private:
+ AppContext m_appContext;
+};
+
+
class TCPServer : public NetServer
{
public:
{
}
+ virtual bool applyExtraSocketOptions(int)
+ {
+ return true;
+ }
+
private:
virtual void clientProcedure() override
{
RUNNER_ASSERT_MSG(server != nullptr, "Couldn't find host " << m_hostName
<< " h_errno = " << hstrerror(h_errno));
+ RUNNER_ASSERT_MSG (applyExtraSocketOptions(sockFd), "Couldn't prepare socket");
+
struct sockaddr_in serverAddress;
memset(&serverAddress, 0, sizeof(serverAddress));
serverAddress.sin_family = AF_INET;
uint16_t m_port;
};
+class UDPMulticastClientApp : public UDPClientApp
+{
+public:
+ UDPMulticastClientApp(const std::string &appPrefix, NetherInternetAccess access, int msgCount,
+ int protocol, const std::string &hostName, uint16_t port, char ttl, bool enableLoop)
+ : UDPClientApp(appPrefix, access, msgCount, protocol, hostName, port)
+ , m_ttl(ttl)
+ , m_enableLoop(enableLoop)
+ {
+ }
+
+ virtual bool applyExtraSocketOptions(int sockFd) override
+ {
+ if (setsockopt(sockFd, IPPROTO_IP, IP_MULTICAST_TTL, (void *) &m_ttl, sizeof(m_ttl)) == -1) {
+ return false;
+ }
+ char multicastEnableLoop = m_enableLoop ? 1 : 0;
+ return setsockopt(sockFd, IPPROTO_IP, IP_MULTICAST_LOOP, static_cast<void *>(&multicastEnableLoop),
+ sizeof(multicastEnableLoop)) == 0;
+ }
+
+private:
+ char m_ttl;
+ bool m_enableLoop;
+};
class TCPClientApp : public NetClient
{
serverAddress.sin_port = htons(m_port);
size_t serverAddressLength = sizeof(serverAddress);
- int ret = TEMP_FAILURE_RETRY(connect(sockFd, reinterpret_cast<struct sockaddr *>(&serverAddress), serverAddressLength));
+ int ret = TEMP_FAILURE_RETRY(connect(sockFd,
+ reinterpret_cast<struct sockaddr *>(&serverAddress),serverAddressLength));
if (ret == -1 && m_expectConnectionError) {
return;
}
}
}
- int m_protocol;
std::string m_hostName;
uint16_t m_port;
bool m_expectConnectionError;
UDPServer udpServer(UDP_TEST_PORT);
udpServer.start(NETHER_NETNS_NAME_TEST);
- UDPClientApp udpClientApp("nether_test_01", NetherInternetAccess::ACCESS_GRANTED, UDP_MESSAGES_COUNT,
- IPPROTO_UDP, REMOTE_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
+ UDPClientApp udpClientApp("nether_test_uciag", NetherInternetAccess::ACCESS_GRANTED, UDP_MESSAGES_COUNT,
+ IPPROTO_UDP, REMOTE_INTERFACE_ADDRESS, UDP_TEST_PORT);
udpClientApp.start();
RUNNER_ASSERT_MSG(udpServer.isAlive(), "UDP server was not running");
UDPServer udpServer(UDP_TEST_PORT);
udpServer.start(NETHER_NETNS_NAME_TEST);
- UDPClientApp udpClientApp("nether_test_02", NetherInternetAccess::ACCESS_DENIED, UDP_MESSAGES_COUNT,
- IPPROTO_UDP, REMOTE_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
+ UDPClientApp udpClientApp("nether_test_uciad", NetherInternetAccess::ACCESS_DENIED, UDP_MESSAGES_COUNT,
+ IPPROTO_UDP, REMOTE_INTERFACE_ADDRESS, UDP_TEST_PORT);
udpClientApp.start();
RUNNER_ASSERT_MSG(udpServer.isAlive(), "UDP server was not running");
UDPServer udpLiteServer(UDP_TEST_PORT, IPPROTO_UDPLITE);
udpLiteServer.start(NETHER_NETNS_NAME_TEST);
- UDPClientApp udpClientApp("nether_test_03", NetherInternetAccess::ACCESS_GRANTED, UDP_MESSAGES_COUNT,
- IPPROTO_UDPLITE, REMOTE_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
+ UDPClientApp udpClientApp("nether_test_ulciag", NetherInternetAccess::ACCESS_GRANTED, UDP_MESSAGES_COUNT,
+ IPPROTO_UDPLITE, REMOTE_INTERFACE_ADDRESS, UDP_TEST_PORT);
udpClientApp.start();
RUNNER_ASSERT_MSG(udpLiteServer.isAlive(), "UDPLite server was not running");
UDPServer udpLiteServer(UDP_TEST_PORT, IPPROTO_UDPLITE);
udpLiteServer.start(NETHER_NETNS_NAME_TEST);
- UDPClientApp udpClientApp("nether_test_04", NetherInternetAccess::ACCESS_DENIED, UDP_MESSAGES_COUNT,
- IPPROTO_UDPLITE, REMOTE_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
+ UDPClientApp udpClientApp("nether_test_ulciad", NetherInternetAccess::ACCESS_DENIED, UDP_MESSAGES_COUNT,
+ IPPROTO_UDPLITE, REMOTE_INTERFACE_ADDRESS, UDP_TEST_PORT);
udpClientApp.start();
RUNNER_ASSERT_MSG(udpLiteServer.isAlive(), "UDP server was not running");
TCPServer tcpServer(TCP_TEST_PORT);
tcpServer.start(NETHER_NETNS_NAME_TEST);
- TCPClientApp tcpClientApp("nether_test_05", NetherInternetAccess::ACCESS_GRANTED, TCP_MESSAGES_COUNT,
- REMOTE_TEST_SERVER_ADDRESS, TCP_TEST_PORT, false);
+ TCPClientApp tcpClientApp("nether_test_tciag", NetherInternetAccess::ACCESS_GRANTED, TCP_MESSAGES_COUNT,
+ REMOTE_INTERFACE_ADDRESS, TCP_TEST_PORT, false);
tcpClientApp.start();
RUNNER_ASSERT_MSG(tcpServer.isAlive(), "TCP server was not running");
TCPServer tcpServer(TCP_TEST_PORT);
tcpServer.start(NETHER_NETNS_NAME_TEST);
- TCPClientApp tcpClientApp("nether_test_06", NetherInternetAccess::ACCESS_DENIED, TCP_MESSAGES_COUNT,
- REMOTE_TEST_SERVER_ADDRESS, TCP_TEST_PORT, true);
+ TCPClientApp tcpClientApp("nether_test_tciad", NetherInternetAccess::ACCESS_DENIED, TCP_MESSAGES_COUNT,
+ REMOTE_INTERFACE_ADDRESS, TCP_TEST_PORT, true);
tcpClientApp.start();
RUNNER_ASSERT_MSG(tcpServer.isAlive(), "TCP server was not running");
RUNNER_ASSERT_MSG(tcpServer.getReceivedBytes() == 0, "TCP server received some data");
}
-
+// Communication between application and local service
RUNNER_TEST_GROUP_INIT(NETHER_LOCAL_SERVICE_CONNECTION)
+RUNNER_CHILD_TEST(nether_check_udp_local_connection_internet_access_granted)
+{
+ RUNNER_IGNORED_MSG("Disabled until the implementation of handling of UDP traffic is finished.");
+ UDPServer udpLiteServer(UDP_TEST_PORT, IPPROTO_UDP);
+ udpLiteServer.start();
+
+ UDPClientApp udpClientApp("nether_test_ulciag", NetherInternetAccess::ACCESS_GRANTED, UDP_MESSAGES_COUNT,
+ IPPROTO_UDP, LOCAL_HOST_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
+ udpClientApp.start();
+
+ RUNNER_ASSERT_MSG(udpLiteServer.isAlive(), "UDP server was not running");
+ udpLiteServer.stop();
+ RUNNER_ASSERT_MSG(udpLiteServer.getReceivedBytes() > 0, "UDP server didn't receive any data");
+}
+
+
RUNNER_CHILD_TEST(nether_check_udp_local_connection_internet_access_denied)
{
RUNNER_IGNORED_MSG("Disabled until the implementation of handling of UDP traffic is finished.");
UDPServer udpLiteServer(UDP_TEST_PORT, IPPROTO_UDP);
udpLiteServer.start();
- UDPClientApp udpClientApp("nether_test_07", NetherInternetAccess::ACCESS_DENIED, UDP_MESSAGES_COUNT,
- IPPROTO_UDP, LOCAL_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
+ UDPClientApp udpClientApp("nether_test_ulciad", NetherInternetAccess::ACCESS_DENIED, UDP_MESSAGES_COUNT,
+ IPPROTO_UDP, LOCAL_HOST_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
+ udpClientApp.start();
+
+ RUNNER_ASSERT_MSG(udpLiteServer.isAlive(), "UDP server was not running");
+ udpLiteServer.stop();
+ RUNNER_ASSERT_MSG(udpLiteServer.getReceivedBytes() > 0, "UDP server didn't receive any data");
+}
+
+
+RUNNER_CHILD_TEST(nether_check_udp_lite_local_connection_internet_access_granted)
+{
+ RUNNER_IGNORED_MSG("Disabled until the implementation of handling of UDP traffic is finished.");
+ UDPServer udpLiteServer(UDP_TEST_PORT, IPPROTO_UDPLITE);
+ udpLiteServer.start();
+
+ UDPClientApp udpClientApp("nether_test_ullciag", NetherInternetAccess::ACCESS_GRANTED, UDP_MESSAGES_COUNT,
+ IPPROTO_UDPLITE, LOCAL_HOST_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
udpClientApp.start();
RUNNER_ASSERT_MSG(udpLiteServer.isAlive(), "UDP server was not running");
UDPServer udpLiteServer(UDP_TEST_PORT, IPPROTO_UDPLITE);
udpLiteServer.start();
- UDPClientApp udpClientApp("nether_test_08", NetherInternetAccess::ACCESS_DENIED, UDP_MESSAGES_COUNT,
- IPPROTO_UDPLITE, LOCAL_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
+ UDPClientApp udpClientApp("nether_test_ullciad", NetherInternetAccess::ACCESS_DENIED, UDP_MESSAGES_COUNT,
+ IPPROTO_UDPLITE, LOCAL_HOST_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
udpClientApp.start();
RUNNER_ASSERT_MSG(udpLiteServer.isAlive(), "UDP server was not running");
}
+RUNNER_CHILD_TEST(nether_check_tcp_local_connection_internet_access_granted)
+{
+ TCPServer tcpServer(TCP_TEST_PORT);
+ tcpServer.start();
+
+ TCPClientApp tcpClientApp("nether_test_tlciad", NetherInternetAccess::ACCESS_GRANTED, TCP_MESSAGES_COUNT,
+ LOCAL_HOST_TEST_SERVER_ADDRESS, TCP_TEST_PORT, false);
+ tcpClientApp.start();
+
+ RUNNER_ASSERT_MSG(tcpServer.isAlive(), "TCP server was not running");
+ tcpServer.stop();
+ RUNNER_ASSERT_MSG(tcpServer.getReceivedBytes() > 0, "TCP server didn't receive any data");
+}
+
+
RUNNER_CHILD_TEST(nether_check_tcp_local_connection_internet_access_denied)
{
TCPServer tcpServer(TCP_TEST_PORT);
tcpServer.start();
- TCPClientApp tcpClientApp("nether_test_09", NetherInternetAccess::ACCESS_DENIED, TCP_MESSAGES_COUNT,
- LOCAL_TEST_SERVER_ADDRESS, TCP_TEST_PORT, false);
+ TCPClientApp tcpClientApp("nether_test_tlciad", NetherInternetAccess::ACCESS_DENIED, TCP_MESSAGES_COUNT,
+ LOCAL_HOST_TEST_SERVER_ADDRESS, TCP_TEST_PORT, false);
tcpClientApp.start();
RUNNER_ASSERT_MSG(tcpServer.isAlive(), "TCP server was not running");
}
+// Applications mustn't communicate with each other even if access to the Internet is granted.
RUNNER_TEST_GROUP_INIT(NETHER_LOCAL_INTER_APP_CONNECTION)
+RUNNER_CHILD_TEST(nether_check_udp_local_inter_app_connection_internet_access_granted)
+{
+ RUNNER_IGNORED_MSG("Disabled until the implementation of handling of UDP traffic is finished.");
+ ScopedAppContext appContext("nether_test_uliaciag_a", NetherInternetAccess::ACCESS_GRANTED);
+ UDPServerApp udpServerApp(UDP_TEST_PORT, IPPROTO_UDP, appContext);
+ udpServerApp.start();
+
+ UDPClientApp udpClientApp("nether_test_uliaciag_b", NetherInternetAccess::ACCESS_GRANTED, UDP_MESSAGES_COUNT,
+ IPPROTO_UDP, LOCAL_HOST_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
+ udpClientApp.start();
+
+ RUNNER_ASSERT_MSG(udpServerApp.isAlive(), "UDP server was not running");
+ udpServerApp.stop();
+ RUNNER_ASSERT_MSG(udpServerApp.getReceivedBytes() == 0, "UDP server received some data");
+}
+
+
RUNNER_CHILD_TEST(nether_check_udp_local_inter_app_connection_internet_access_denied)
{
RUNNER_IGNORED_MSG("Disabled until the implementation of handling of UDP traffic is finished.");
- ScopedAppContext appContext("nether_test_10a", NetherInternetAccess::ACCESS_DENIED);
+ ScopedAppContext appContext("nether_test_uliaciad_a", NetherInternetAccess::ACCESS_DENIED);
UDPServerApp udpServerApp(UDP_TEST_PORT, IPPROTO_UDP, appContext);
udpServerApp.start();
- UDPClientApp udpClientApp("nether_test_10b", NetherInternetAccess::ACCESS_DENIED, UDP_MESSAGES_COUNT,
- IPPROTO_UDP, LOCAL_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
+ UDPClientApp udpClientApp("nether_test_uliaciad_b", NetherInternetAccess::ACCESS_DENIED, UDP_MESSAGES_COUNT,
+ IPPROTO_UDP, LOCAL_HOST_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
udpClientApp.start();
RUNNER_ASSERT_MSG(udpServerApp.isAlive(), "UDP server was not running");
udpServerApp.stop();
- RUNNER_ASSERT_MSG(udpServerApp.getReceivedBytes() > 0, "UDP server didn't receive any data");
+ RUNNER_ASSERT_MSG(udpServerApp.getReceivedBytes() == 0, "UDP server received some data");
+}
+
+
+RUNNER_CHILD_TEST(nether_check_udp_lite_local_inter_app_connection_internet_access_granted)
+{
+ RUNNER_IGNORED_MSG("Disabled until the implementation of handling of UDP traffic is finished.");
+ ScopedAppContext appContext("nether_test_ulliaciag_a", NetherInternetAccess::ACCESS_GRANTED);
+ UDPServerApp udpLiteServerApp(UDP_TEST_PORT, IPPROTO_UDPLITE, appContext);
+ udpLiteServerApp.start();
+
+ UDPClientApp udpClientApp("nether_ulliaciag_b", NetherInternetAccess::ACCESS_GRANTED, UDP_MESSAGES_COUNT,
+ IPPROTO_UDPLITE, LOCAL_HOST_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
+ udpClientApp.start();
+
+ RUNNER_ASSERT_MSG(udpLiteServerApp.isAlive(), "UDP server was not running");
+ udpLiteServerApp.stop();
+ RUNNER_ASSERT_MSG(udpLiteServerApp.getReceivedBytes() == 0, "UDP server received some data");
}
RUNNER_CHILD_TEST(nether_check_udp_lite_local_inter_app_connection_internet_access_denied)
{
RUNNER_IGNORED_MSG("Disabled until the implementation of handling of UDP traffic is finished.");
- ScopedAppContext appContext("nether_test_11a", NetherInternetAccess::ACCESS_DENIED);
+ ScopedAppContext appContext("nether_test_ulliaciad_a", NetherInternetAccess::ACCESS_DENIED);
UDPServerApp udpLiteServerApp(UDP_TEST_PORT, IPPROTO_UDPLITE, appContext);
udpLiteServerApp.start();
- UDPClientApp udpClientApp("nether_test_11b", NetherInternetAccess::ACCESS_DENIED, UDP_MESSAGES_COUNT,
- IPPROTO_UDPLITE, LOCAL_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
+ UDPClientApp udpClientApp("nether_ulliaciad_b", NetherInternetAccess::ACCESS_DENIED, UDP_MESSAGES_COUNT,
+ IPPROTO_UDPLITE, LOCAL_HOST_TEST_SERVER_ADDRESS, UDP_TEST_PORT);
udpClientApp.start();
RUNNER_ASSERT_MSG(udpLiteServerApp.isAlive(), "UDP server was not running");
udpLiteServerApp.stop();
- RUNNER_ASSERT_MSG(udpLiteServerApp.getReceivedBytes() > 0, "UDP server didn't receive any data");
+ RUNNER_ASSERT_MSG(udpLiteServerApp.getReceivedBytes() == 0, "UDP server received some data");
+}
+
+
+RUNNER_CHILD_TEST(nether_check_tcp_local_inter_app_connection_internet_access_granted)
+{
+ ScopedAppContext appContext("nether_test_tliaciag_a", NetherInternetAccess::ACCESS_GRANTED);
+ TCPServerApp tcpServerApp(TCP_TEST_PORT, appContext);
+ tcpServerApp.start();
+
+ TCPClientApp tcpClientApp("nether_test_tliaciag_b", NetherInternetAccess::ACCESS_GRANTED, TCP_MESSAGES_COUNT,
+ LOCAL_HOST_TEST_SERVER_ADDRESS, TCP_TEST_PORT, true);
+ tcpClientApp.start();
+
+ RUNNER_ASSERT_MSG(tcpServerApp.isAlive(), "TCP server was not running");
+ tcpServerApp.stop();
+ RUNNER_ASSERT_MSG(tcpServerApp.getReceivedBytes() == 0, "TCP server received some data");
}
RUNNER_CHILD_TEST(nether_check_tcp_local_inter_app_connection_internet_access_denied)
{
- ScopedAppContext appContext("nether_test_12a", NetherInternetAccess::ACCESS_DENIED);
+ ScopedAppContext appContext("nether_test_tliaciad_a", NetherInternetAccess::ACCESS_DENIED);
TCPServerApp tcpServerApp(TCP_TEST_PORT, appContext);
tcpServerApp.start();
- TCPClientApp tcpClientApp("nether_test_12b", NetherInternetAccess::ACCESS_DENIED, TCP_MESSAGES_COUNT,
- LOCAL_TEST_SERVER_ADDRESS, TCP_TEST_PORT, false);
+ TCPClientApp tcpClientApp("nether_test_tliaciad_b", NetherInternetAccess::ACCESS_DENIED, TCP_MESSAGES_COUNT,
+ LOCAL_HOST_TEST_SERVER_ADDRESS, TCP_TEST_PORT, true);
tcpClientApp.start();
RUNNER_ASSERT_MSG(tcpServerApp.isAlive(), "TCP server was not running");
tcpServerApp.stop();
- RUNNER_ASSERT_MSG(tcpServerApp.getReceivedBytes() > 0, "TCP server didn't receive any data");
+ RUNNER_ASSERT_MSG(tcpServerApp.getReceivedBytes() == 0, "TCP server received some data");
+}
+
+
+RUNNER_TEST_GROUP_INIT(NETHER_MULTICAST)
+
+
+RUNNER_CHILD_TEST(nether_check_multicast_inter_app_connection_access_granted)
+{
+ // one app acts as a server (receiver), the second as a sender
+ RUNNER_IGNORED_MSG("Disabled until the implementation of handling of UDP traffic is finished.");
+ ScopedAppContext appContext("nether_test_miacag_a", NetherInternetAccess::ACCESS_GRANTED);
+ UDPMulticastServerApp udpMulticastServerApp(UDP_TEST_PORT, IPPROTO_UDP, LOCAL_TEST_MCAST_GROUP,
+ ANY_INTERFACE, appContext);
+ udpMulticastServerApp.start();
+
+ UDPMulticastClientApp udpMulticastClientApp("nether_test_miacag_b", NetherInternetAccess::ACCESS_GRANTED,
+ UDP_MESSAGES_COUNT, IPPROTO_UDP, LOCAL_TEST_MCAST_GROUP, UDP_TEST_PORT, TTL_MCAST_RESTRIC_SUBNET, true);
+ udpMulticastClientApp.start();
+
+ RUNNER_ASSERT_MSG(udpMulticastServerApp.isAlive(), "UDP multicast server was not running");
+ udpMulticastServerApp.stop();
+ RUNNER_ASSERT_MSG(udpMulticastServerApp.getReceivedBytes() > 0, "UDP multicast server didn't receive any data");
+}
+
+
+RUNNER_CHILD_TEST(nether_check_multicast_inter_app_connection_access_denied)
+{
+ RUNNER_IGNORED_MSG("Disabled until the implementation of handling of UDP traffic is finished.");
+ ScopedAppContext appContext("nether_test_miacad_a", NetherInternetAccess::ACCESS_DENIED);
+ UDPMulticastServerApp udpMulticastServerApp(UDP_TEST_PORT, IPPROTO_UDP, LOCAL_TEST_MCAST_GROUP,
+ ANY_INTERFACE, appContext);
+ udpMulticastServerApp.start();
+
+ UDPMulticastClientApp udpMulticastClientApp("nether_test_miacad_b", NetherInternetAccess::ACCESS_DENIED,
+ UDP_MESSAGES_COUNT, IPPROTO_UDP, LOCAL_TEST_MCAST_GROUP, UDP_TEST_PORT, TTL_MCAST_RESTRIC_SUBNET, true);
+ udpMulticastClientApp.start();
+
+ RUNNER_ASSERT_MSG(udpMulticastServerApp.isAlive(), "UDP multicast server was not running");
+ udpMulticastServerApp.stop();
+ RUNNER_ASSERT_MSG(udpMulticastServerApp.getReceivedBytes() > 0, "UDP multicast server didn't receive any data");
+}
+
+
+RUNNER_CHILD_TEST(nether_check_multicast_remote_connection_app_sender_access_granted)
+{
+ RUNNER_IGNORED_MSG("Disabled until the implementation of handling of UDP traffic is finished.");
+ ScopedShellScriptRunner networkNSRunner(NETHER_NETNS_SETUP_COMMAND,
+ NETHER_NETNS_TEARDOWN_COMMAND);
+
+ UDPMulticastServer udpMulticastServer(UDP_TEST_PORT, IPPROTO_UDP, LOCAL_TEST_MCAST_GROUP, REMOTE_INTERFACE_NAME);
+ udpMulticastServer.start(NETHER_NETNS_NAME_TEST);
+
+ UDPMulticastClientApp udpMulticastClientApp("nether_test_mrcasag", NetherInternetAccess::ACCESS_GRANTED,
+ UDP_MESSAGES_COUNT, IPPROTO_UDP, LOCAL_TEST_MCAST_GROUP, UDP_TEST_PORT, TTL_MCAST_RESTRIC_SUBNET, false);
+ udpMulticastClientApp.start();
+
+ RUNNER_ASSERT_MSG(udpMulticastServer.isAlive(), "UDP multicast server was not running");
+ udpMulticastServer.stop();
+ RUNNER_ASSERT_MSG(udpMulticastServer.getReceivedBytes() > 0, "UDP multicast server didn't receive any data");
+}
+
+
+RUNNER_CHILD_TEST(nether_check_multicast_remote_connection_app_sender_access_denied)
+{
+ RUNNER_IGNORED_MSG("Disabled until the implementation of handling of UDP traffic is finished.");
+ ScopedShellScriptRunner networkNSRunner(NETHER_NETNS_SETUP_COMMAND,
+ NETHER_NETNS_TEARDOWN_COMMAND);
+
+ UDPMulticastServer udpMulticastServer(UDP_TEST_PORT, IPPROTO_UDP, LOCAL_TEST_MCAST_GROUP, REMOTE_INTERFACE_NAME);
+ udpMulticastServer.start(NETHER_NETNS_NAME_TEST);
+
+ UDPMulticastClientApp udpMulticastClientApp("nether_test_mrcasad", NetherInternetAccess::ACCESS_DENIED,
+ UDP_MESSAGES_COUNT, IPPROTO_UDP, LOCAL_TEST_MCAST_GROUP, UDP_TEST_PORT, TTL_MCAST_RESTRIC_SUBNET, false);
+ udpMulticastClientApp.start();
+
+ RUNNER_ASSERT_MSG(udpMulticastServer.isAlive(), "UDP multicast server was not running");
+ udpMulticastServer.stop();
+ RUNNER_ASSERT_MSG(udpMulticastServer.getReceivedBytes() == 0, "UDP multicast server received some data");
}
RUNNER_ASSERT_MSG(server != nullptr, "Couldn't find host "
<< DNS_TEST_ADDRESS << " h_errno = " << h_errno);
};
-
- runProcedureInNetAppContext("nether_test_13", getHostAddress, NetherInternetAccess::ACCESS_GRANTED);
+ runProcedureInNetAppContext("nether_test_giag", getHostAddress, NetherInternetAccess::ACCESS_GRANTED);
}
RUNNER_ASSERT_MSG(server == nullptr, "Host was found " << DNS_TEST_ADDRESS);
};
- runProcedureInNetAppContext("nether_test_14", getHostAddress, NetherInternetAccess::ACCESS_DENIED);
+ runProcedureInNetAppContext("nether_test_giad", getHostAddress, NetherInternetAccess::ACCESS_DENIED);
}
RUNNER_CHILD_TEST(nether_check_raw_socket_access_granted)
{
- runProcedureInNetAppContext("nether_test_15", checkRawSocket, NetherInternetAccess::ACCESS_GRANTED);
+ runProcedureInNetAppContext("nether_test_rsag", checkRawSocket, NetherInternetAccess::ACCESS_GRANTED);
}
RUNNER_CHILD_TEST(nether_check_raw_socket_access_denied)
{
- runProcedureInNetAppContext("nether_test_16", checkRawSocket, NetherInternetAccess::ACCESS_DENIED);
+ runProcedureInNetAppContext("nether_test_rsad", checkRawSocket, NetherInternetAccess::ACCESS_DENIED);
}