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

[Inet] Split off per-implementation parts of InetInterface #13228

Closed
Closed
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
2 changes: 1 addition & 1 deletion examples/chip-tool/commands/common/Command.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ static bool ParseAddressWithInterface(const char * addressString, Command::Addre
{
struct sockaddr_in6 * addr = reinterpret_cast<struct sockaddr_in6 *>(result->ai_addr);
address->address = ::chip::Inet::IPAddress::FromSockAddr(*addr);
address->interfaceId = ::chip::Inet::InterfaceId(addr->sin6_scope_id);
address->interfaceId = ::chip::Inet::PlatformNetworkInterface::ToInterfaceId(addr->sin6_scope_id);
}
#if INET_CONFIG_ENABLE_IPV4
else if (result->ai_family == AF_INET)
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal-mdns/AllInterfaceListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class AllInterfaces : public mdns::Minimal::ListenIterator
return true; // not a usable interface
}

char name[chip::Inet::InterfaceId::kMaxIfNameLength];
char name[chip::Inet::PlatformNetworkInterface::kMaxNameLength];
if (mIterator.GetInterfaceName(name, sizeof(name)) != CHIP_NO_ERROR)
{
printf("!!!! FAILED TO GET INTERFACE NAME\n");
Expand Down
4 changes: 2 additions & 2 deletions examples/minimal-mdns/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ class ReportDelegate : public mdns::Minimal::ServerDelegate
info->SrcAddress.ToString(addr, sizeof(addr));

char ifName[64];
VerifyOrDie(info->Interface.GetInterfaceName(ifName, sizeof(ifName)) == CHIP_NO_ERROR);
VerifyOrDie(Inet::PlatformNetworkInterface::GetInterfaceName(info->Interface, ifName, sizeof(ifName)) == CHIP_NO_ERROR);

printf("QUERY from: %-15s on port %d, via interface %s\n", addr, info->SrcPort, ifName);
Report("QUERY: ", data);
Expand All @@ -199,7 +199,7 @@ class ReportDelegate : public mdns::Minimal::ServerDelegate
info->SrcAddress.ToString(addr, sizeof(addr));

char ifName[64];
VerifyOrDie(info->Interface.GetInterfaceName(ifName, sizeof(ifName)) == CHIP_NO_ERROR);
VerifyOrDie(Inet::PlatformNetworkInterface::GetInterfaceName(info->Interface, ifName, sizeof(ifName)) == CHIP_NO_ERROR);

printf("RESPONSE from: %-15s on port %d, via interface %s\n", addr, info->SrcPort, ifName);
Report("RESPONSE: ", data);
Expand Down
4 changes: 2 additions & 2 deletions examples/minimal-mdns/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class ReplyDelegate : public mdns::Minimal::ServerDelegate, public mdns::Minimal
info->SrcAddress.ToString(addr, sizeof(addr));

char ifName[64];
VerifyOrDie(info->Interface.GetInterfaceName(ifName, sizeof(ifName)) == CHIP_NO_ERROR);
VerifyOrDie(Inet::PlatformNetworkInterface::GetInterfaceName(info->Interface, ifName, sizeof(ifName)) == CHIP_NO_ERROR);

printf("QUERY from: %-15s on port %d, via interface %s\n", addr, info->SrcPort, ifName);
Report("QUERY: ", data);
Expand All @@ -135,7 +135,7 @@ class ReplyDelegate : public mdns::Minimal::ServerDelegate, public mdns::Minimal
info->SrcAddress.ToString(addr, sizeof(addr));

char ifName[64];
VerifyOrDie(info->Interface.GetInterfaceName(ifName, sizeof(ifName)) == CHIP_NO_ERROR);
VerifyOrDie(Inet::PlatformNetworkInterface::GetInterfaceName(info->Interface, ifName, sizeof(ifName)) == CHIP_NO_ERROR);

printf("RESPONSE from: %-15s on port %d, via interface %s\n", addr, info->SrcPort, ifName);
}
Expand Down
2 changes: 1 addition & 1 deletion src/controller/python/chip/discovery/NodeResolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class PythonResolverDelegate : public ResolverDelegate
mSuccessCallback( //
nodeData.mPeerId.GetCompressedFabricId(), //
nodeData.mPeerId.GetNodeId(), //
nodeData.mInterfaceId.GetPlatformInterface(), //
Inet::PlatformNetworkInterface::FromInterfaceId(nodeData.mInterfaceId), //
nodeData.mAddress[0].ToString(ipAddressBuffer, sizeof(ipAddressBuffer)), //
nodeData.mPort //
);
Expand Down
2 changes: 1 addition & 1 deletion src/include/platform/DiagnosticDataProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ struct ThreadMetrics : public app::Clusters::SoftwareDiagnostics::Structs::Threa

struct NetworkInterface : public app::Clusters::GeneralDiagnostics::Structs::NetworkInterfaceType::Type
{
char Name[Inet::InterfaceId::kMaxIfNameLength];
char Name[Inet::PlatformNetworkInterface::kMaxNameLength];
uint8_t MacAddress[kMaxHardwareAddrSize];
NetworkInterface * Next; /* Pointer to the next structure. */
};
Expand Down
27 changes: 26 additions & 1 deletion src/inet/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,37 @@ buildconfig_header("inet_buildconfig") {
[ "INET_PLATFORM_CONFIG_INCLUDE=${chip_inet_platform_config_include}" ]
}

defines += [ "INET_TCP_END_POINT_IMPL_CONFIG_FILE=<inet/TCPEndPointImpl${chip_system_config_inet}.h>" ]
defines += [
"INET_INTERFACE_IMPL_CONFIG_FILE=<inet/InetInterfaceImpl${chip_system_config_inet_interface}.h>",
"INET_TCP_END_POINT_IMPL_CONFIG_FILE=<inet/TCPEndPointImpl${chip_system_config_inet}.h>",
]
if (chip_system_config_use_open_thread_udp) {
defines += [
"INET_UDP_END_POINT_IMPL_CONFIG_FILE=<inet/UDPEndPointImpl_OpenThread.h>",
]
} else {
defines += [ "INET_UDP_END_POINT_IMPL_CONFIG_FILE=<inet/UDPEndPointImpl${chip_system_config_inet}.h>" ]
}

if (chip_system_config_inet_interface == "LwIP") {
defines += [
"CHIP_SYSTEM_CONFIG_USE_LWIP=1",
"CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS=0",
"CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF=0",
]
} else if (chip_system_config_inet_interface == "IFAddrs") {
defines += [
"CHIP_SYSTEM_CONFIG_USE_LWIP=0",
"CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS=1",
"CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF=0",
]
} else if (chip_system_config_inet_interface == "Zephyr") {
defines += [
"CHIP_SYSTEM_CONFIG_USE_LWIP=0",
"CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS=0",
"CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF=1",
]
}
}

source_set("inet_config_header") {
Expand Down Expand Up @@ -97,6 +120,8 @@ static_library("inet") {
"InetFaultInjection.h",
"InetInterface.cpp",
"InetInterface.h",
"InetInterfaceImpl${chip_system_config_inet_interface}.cpp",
"InetInterfaceImpl${chip_system_config_inet_interface}.h",
"InetLayer.h",
"arpa-inet-compatibility.h",
]
Expand Down
Loading