Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove TAP support from lwip/standalone #31886

Merged
merged 1 commit into from
Feb 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 0 additions & 28 deletions src/inet/tests/TapAddrAutoconf.h

This file was deleted.

113 changes: 5 additions & 108 deletions src/inet/tests/TestInetCommonPosix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,12 @@
#include <netif/etharp.h>

#if CHIP_TARGET_STYLE_UNIX

// TapAddrAutoconf and TapInterface are only needed for LwIP on
// sockets simulation in which a host tap/tun interface is used to
// proxy the LwIP stack onto a host native network interface.

#include "TapAddrAutoconf.h"
#include "TapInterface.h"
// NOTE: this used to be supported, so could theoretically be
// recovered, however the TAP/TUN was never actually used
// and the underlying files were never compiled in CHIP.
#error "Testing of LWIP on unix systems via TAP not supported."
#endif // CHIP_TARGET_STYLE_UNIX

#endif // CHIP_SYSTEM_CONFIG_USE_LWIP

using namespace chip;
Expand Down Expand Up @@ -110,14 +108,6 @@ static void ReleaseLwIP(void)
#endif // (LWIP_VERSION_MAJOR == 2) && (LWIP_VERSION_MINOR == 0)
}

#if CHIP_TARGET_STYLE_UNIX
// TapAddrAutoconf and TapInterface are only needed for LwIP on
// sockets simulation in which a host tap/tun interface is used to
// proxy the LwIP stack onto a host native network interface.
// CollectTapAddresses() is only available on such targets.
static std::vector<TapInterface> sTapIFs;
#endif // CHIP_TARGET_STYLE_UNIX

static std::vector<struct netif> sNetIFs; // interface to filter

static bool NetworkIsReady();
Expand Down Expand Up @@ -196,28 +186,11 @@ static void PrintNetworkState()
for (size_t j = 0; j < gNetworkOptions.TapDeviceName.size(); j++)
{
struct netif * netIF = &(sNetIFs[j]);
#if CHIP_TARGET_STYLE_UNIX
// TapAddrAutoconf and TapInterface are only needed for LwIP on
// sockets simulation in which a host tap/tun interface is used to
// proxy the LwIP stack onto a host native network interface.
// CollectTapAddresses() is only available on such targets.

TapInterface * tapIF = &(sTapIFs[j]);
#endif // CHIP_TARGET_STYLE_UNIX
InterfaceId(netIF).GetInterfaceName(intfName, sizeof(intfName));

printf("LwIP interface ready\n");
printf(" Interface Name: %s\n", intfName);
printf(" Tap Device: %s\n", gNetworkOptions.TapDeviceName[j]);
#if CHIP_TARGET_STYLE_UNIX
// TapAddrAutoconf and TapInterface are only needed for LwIP on
// sockets simulation in which a host tap/tun interface is used to
// proxy the LwIP stack onto a host native network interface.
// CollectTapAddresses() is only available on such targets.

printf(" MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n", tapIF->macAddr[0], tapIF->macAddr[1], tapIF->macAddr[2],
tapIF->macAddr[3], tapIF->macAddr[4], tapIF->macAddr[5]);
#endif // CHIP_TARGET_STYLE_UNIX

#if INET_CONFIG_ENABLE_IPV4
printf(" IPv4 Address: %s\n", ipaddr_ntoa(&(netIF->ip_addr)));
Expand Down Expand Up @@ -253,52 +226,14 @@ void InitNetwork()
}
}

#if CHIP_TARGET_STYLE_UNIX
// TapAddrAutoconf and TapInterface are only needed for LwIP on
// sockets simulation in which a host tap/tun interface is used to
// proxy the LwIP stack onto a host native network interface.
// CollectTapAddresses() is only available on such targets.

sTapIFs.clear();
#endif // CHIP_TARGET_STYLE_UNIX
sNetIFs.clear();

for (size_t j = 0; j < gNetworkOptions.TapDeviceName.size(); j++)
{
#if CHIP_TARGET_STYLE_UNIX
// TapAddrAutoconf and TapInterface are only needed for LwIP on
// sockets simulation in which a host tap/tun interface is used to
// proxy the LwIP stack onto a host native network interface.
// CollectTapAddresses() is only available on such targets.

TapInterface tapIF;
sTapIFs.push_back(tapIF);
#endif // CHIP_TARGET_STYLE_UNIX
struct netif netIF;
sNetIFs.push_back(netIF);
}

#if CHIP_TARGET_STYLE_UNIX

// TapAddrAutoconf and TapInterface are only needed for LwIP on
// sockets simulation in which a host tap/tun interface is used to
// proxy the LwIP stack onto a host native network interface.
// CollectTapAddresses() is only available on such targets.

err_t lwipErr;

for (size_t j = 0; j < gNetworkOptions.TapDeviceName.size(); j++)
{
lwipErr = TapInterface_Init(&(sTapIFs[j]), gNetworkOptions.TapDeviceName[j], NULL);
if (lwipErr != ERR_OK)
{
printf("Failed to initialize tap device %s: %s\n", gNetworkOptions.TapDeviceName[j],
ErrorStr(System::MapErrorLwIP(lwipErr)));
exit(EXIT_FAILURE);
}
}
#endif // CHIP_TARGET_STYLE_UNIX

tcpip_init(OnLwIPInitComplete, NULL);

// Lock LwIP stack
Expand All @@ -310,17 +245,6 @@ void InitNetwork()

addrsVec.clear();

#if CHIP_TARGET_STYLE_UNIX

// TapAddrAutoconf and TapInterface are only needed for LwIP on
// sockets simulation in which a host tap/tun interface is used to
// proxy the LwIP stack onto a host native network interface.
// CollectTapAddresses() is only available on such targets.
if (gNetworkOptions.TapUseSystemConfig)
{
CollectTapAddresses(addrsVec, gNetworkOptions.TapDeviceName[j]);
}
#endif // CHIP_TARGET_STYLE_UNIX
#if INET_CONFIG_ENABLE_IPV4

IPAddress ip4Addr = (j < gNetworkOptions.LocalIPv4Addr.size()) ? gNetworkOptions.LocalIPv4Addr[j] : IPAddress::Any;
Expand All @@ -333,25 +257,6 @@ void InitNetwork()
}
}

#if CHIP_TARGET_STYLE_UNIX
// TapAddrAutoconf and TapInterface are only needed for LwIP on
// sockets simulation in which a host tap/tun interface is used to
// proxy the LwIP stack onto a host native network interface.
// CollectTapAddresses() is only available on such targets.

IPAddress ip4Gateway = (j < gNetworkOptions.IPv4GatewayAddr.size()) ? gNetworkOptions.IPv4GatewayAddr[j] : IPAddress::Any;

{
ip4_addr_t ip4AddrLwIP, ip4NetmaskLwIP, ip4GatewayLwIP;

ip4AddrLwIP = ip4Addr.ToIPv4();
IP4_ADDR(&ip4NetmaskLwIP, 255, 255, 255, 0);
ip4GatewayLwIP = ip4Gateway.ToIPv4();
netif_add(&(sNetIFs[j]), &ip4AddrLwIP, &ip4NetmaskLwIP, &ip4GatewayLwIP, &(sTapIFs[j]), TapInterface_SetupNetif,
tcpip_input);
}
#endif // CHIP_TARGET_STYLE_UNIX

#endif // INET_CONFIG_ENABLE_IPV4

netif_create_ip6_linklocal_address(&(sNetIFs[j]), 1);
Expand Down Expand Up @@ -484,14 +389,6 @@ void ServiceEvents(uint32_t aSleepTimeMilliseconds)

gSystemLayer.HandlePlatformTimer();
}
#if CHIP_TARGET_STYLE_UNIX
// TapAddrAutoconf and TapInterface are only needed for LwIP on
// sockets simulation in which a host tap/tun interface is used to
// proxy the LwIP stack onto a host native network interface.
// CollectTapAddresses() is only available on such targets.

TapInterface_Select(&(sTapIFs[0]), &(sNetIFs[0]), aSleepTime, gNetworkOptions.TapDeviceName.size());
#endif // CHIP_TARGET_STYLE_UNIX
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
}

Expand Down
Loading
Loading