Skip to content

Commit bb24d97

Browse files
authored
Remove TAP support from lwip (project-chip#31886)
1 parent 5677529 commit bb24d97

File tree

4 files changed

+5
-744
lines changed

4 files changed

+5
-744
lines changed

src/inet/tests/TapAddrAutoconf.h

-28
This file was deleted.

src/inet/tests/TestInetCommonPosix.cpp

+5-108
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,12 @@
6565
#include <netif/etharp.h>
6666

6767
#if CHIP_TARGET_STYLE_UNIX
68-
69-
// TapAddrAutoconf and TapInterface are only needed for LwIP on
70-
// sockets simulation in which a host tap/tun interface is used to
71-
// proxy the LwIP stack onto a host native network interface.
72-
73-
#include "TapAddrAutoconf.h"
74-
#include "TapInterface.h"
68+
// NOTE: this used to be supported, so could theoretically be
69+
// recovered, however the TAP/TUN was never actually used
70+
// and the underlying files were never compiled in CHIP.
71+
#error "Testing of LWIP on unix systems via TAP not supported."
7572
#endif // CHIP_TARGET_STYLE_UNIX
73+
7674
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
7775

7876
using namespace chip;
@@ -110,14 +108,6 @@ static void ReleaseLwIP(void)
110108
#endif // (LWIP_VERSION_MAJOR == 2) && (LWIP_VERSION_MINOR == 0)
111109
}
112110

113-
#if CHIP_TARGET_STYLE_UNIX
114-
// TapAddrAutoconf and TapInterface are only needed for LwIP on
115-
// sockets simulation in which a host tap/tun interface is used to
116-
// proxy the LwIP stack onto a host native network interface.
117-
// CollectTapAddresses() is only available on such targets.
118-
static std::vector<TapInterface> sTapIFs;
119-
#endif // CHIP_TARGET_STYLE_UNIX
120-
121111
static std::vector<struct netif> sNetIFs; // interface to filter
122112

123113
static bool NetworkIsReady();
@@ -196,28 +186,11 @@ static void PrintNetworkState()
196186
for (size_t j = 0; j < gNetworkOptions.TapDeviceName.size(); j++)
197187
{
198188
struct netif * netIF = &(sNetIFs[j]);
199-
#if CHIP_TARGET_STYLE_UNIX
200-
// TapAddrAutoconf and TapInterface are only needed for LwIP on
201-
// sockets simulation in which a host tap/tun interface is used to
202-
// proxy the LwIP stack onto a host native network interface.
203-
// CollectTapAddresses() is only available on such targets.
204-
205-
TapInterface * tapIF = &(sTapIFs[j]);
206-
#endif // CHIP_TARGET_STYLE_UNIX
207189
InterfaceId(netIF).GetInterfaceName(intfName, sizeof(intfName));
208190

209191
printf("LwIP interface ready\n");
210192
printf(" Interface Name: %s\n", intfName);
211193
printf(" Tap Device: %s\n", gNetworkOptions.TapDeviceName[j]);
212-
#if CHIP_TARGET_STYLE_UNIX
213-
// TapAddrAutoconf and TapInterface are only needed for LwIP on
214-
// sockets simulation in which a host tap/tun interface is used to
215-
// proxy the LwIP stack onto a host native network interface.
216-
// CollectTapAddresses() is only available on such targets.
217-
218-
printf(" MAC address: %02x:%02x:%02x:%02x:%02x:%02x\n", tapIF->macAddr[0], tapIF->macAddr[1], tapIF->macAddr[2],
219-
tapIF->macAddr[3], tapIF->macAddr[4], tapIF->macAddr[5]);
220-
#endif // CHIP_TARGET_STYLE_UNIX
221194

222195
#if INET_CONFIG_ENABLE_IPV4
223196
printf(" IPv4 Address: %s\n", ipaddr_ntoa(&(netIF->ip_addr)));
@@ -253,52 +226,14 @@ void InitNetwork()
253226
}
254227
}
255228

256-
#if CHIP_TARGET_STYLE_UNIX
257-
// TapAddrAutoconf and TapInterface are only needed for LwIP on
258-
// sockets simulation in which a host tap/tun interface is used to
259-
// proxy the LwIP stack onto a host native network interface.
260-
// CollectTapAddresses() is only available on such targets.
261-
262-
sTapIFs.clear();
263-
#endif // CHIP_TARGET_STYLE_UNIX
264229
sNetIFs.clear();
265230

266231
for (size_t j = 0; j < gNetworkOptions.TapDeviceName.size(); j++)
267232
{
268-
#if CHIP_TARGET_STYLE_UNIX
269-
// TapAddrAutoconf and TapInterface are only needed for LwIP on
270-
// sockets simulation in which a host tap/tun interface is used to
271-
// proxy the LwIP stack onto a host native network interface.
272-
// CollectTapAddresses() is only available on such targets.
273-
274-
TapInterface tapIF;
275-
sTapIFs.push_back(tapIF);
276-
#endif // CHIP_TARGET_STYLE_UNIX
277233
struct netif netIF;
278234
sNetIFs.push_back(netIF);
279235
}
280236

281-
#if CHIP_TARGET_STYLE_UNIX
282-
283-
// TapAddrAutoconf and TapInterface are only needed for LwIP on
284-
// sockets simulation in which a host tap/tun interface is used to
285-
// proxy the LwIP stack onto a host native network interface.
286-
// CollectTapAddresses() is only available on such targets.
287-
288-
err_t lwipErr;
289-
290-
for (size_t j = 0; j < gNetworkOptions.TapDeviceName.size(); j++)
291-
{
292-
lwipErr = TapInterface_Init(&(sTapIFs[j]), gNetworkOptions.TapDeviceName[j], NULL);
293-
if (lwipErr != ERR_OK)
294-
{
295-
printf("Failed to initialize tap device %s: %s\n", gNetworkOptions.TapDeviceName[j],
296-
ErrorStr(System::MapErrorLwIP(lwipErr)));
297-
exit(EXIT_FAILURE);
298-
}
299-
}
300-
#endif // CHIP_TARGET_STYLE_UNIX
301-
302237
tcpip_init(OnLwIPInitComplete, NULL);
303238

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

311246
addrsVec.clear();
312247

313-
#if CHIP_TARGET_STYLE_UNIX
314-
315-
// TapAddrAutoconf and TapInterface are only needed for LwIP on
316-
// sockets simulation in which a host tap/tun interface is used to
317-
// proxy the LwIP stack onto a host native network interface.
318-
// CollectTapAddresses() is only available on such targets.
319-
if (gNetworkOptions.TapUseSystemConfig)
320-
{
321-
CollectTapAddresses(addrsVec, gNetworkOptions.TapDeviceName[j]);
322-
}
323-
#endif // CHIP_TARGET_STYLE_UNIX
324248
#if INET_CONFIG_ENABLE_IPV4
325249

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

336-
#if CHIP_TARGET_STYLE_UNIX
337-
// TapAddrAutoconf and TapInterface are only needed for LwIP on
338-
// sockets simulation in which a host tap/tun interface is used to
339-
// proxy the LwIP stack onto a host native network interface.
340-
// CollectTapAddresses() is only available on such targets.
341-
342-
IPAddress ip4Gateway = (j < gNetworkOptions.IPv4GatewayAddr.size()) ? gNetworkOptions.IPv4GatewayAddr[j] : IPAddress::Any;
343-
344-
{
345-
ip4_addr_t ip4AddrLwIP, ip4NetmaskLwIP, ip4GatewayLwIP;
346-
347-
ip4AddrLwIP = ip4Addr.ToIPv4();
348-
IP4_ADDR(&ip4NetmaskLwIP, 255, 255, 255, 0);
349-
ip4GatewayLwIP = ip4Gateway.ToIPv4();
350-
netif_add(&(sNetIFs[j]), &ip4AddrLwIP, &ip4NetmaskLwIP, &ip4GatewayLwIP, &(sTapIFs[j]), TapInterface_SetupNetif,
351-
tcpip_input);
352-
}
353-
#endif // CHIP_TARGET_STYLE_UNIX
354-
355260
#endif // INET_CONFIG_ENABLE_IPV4
356261

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

485390
gSystemLayer.HandlePlatformTimer();
486391
}
487-
#if CHIP_TARGET_STYLE_UNIX
488-
// TapAddrAutoconf and TapInterface are only needed for LwIP on
489-
// sockets simulation in which a host tap/tun interface is used to
490-
// proxy the LwIP stack onto a host native network interface.
491-
// CollectTapAddresses() is only available on such targets.
492-
493-
TapInterface_Select(&(sTapIFs[0]), &(sNetIFs[0]), aSleepTime, gNetworkOptions.TapDeviceName.size());
494-
#endif // CHIP_TARGET_STYLE_UNIX
495392
#endif // CHIP_SYSTEM_CONFIG_USE_LWIP
496393
}
497394

0 commit comments

Comments
 (0)