2 * Copyright (c) 2020 Project CHIP Authors
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 * This file implements the utility class for the CHIP Message Layer.
25 #include <messaging/ErrorCategory.h>
27 #include <inet/InetError.h>
28 #include <system/SystemConfig.h>
29 #include <system/SystemError.h>
34 bool IsIgnoredMulticastSendError(CHIP_ERROR err)
36 return err == CHIP_NO_ERROR ||
37 #if CHIP_SYSTEM_CONFIG_USE_LWIP
38 err == System::MapErrorLwIP(ERR_RTE)
40 err == System::MapErrorPOSIX(ENETUNREACH) || err == System::MapErrorPOSIX(EADDRNOTAVAIL)
45 CHIP_ERROR FilterUDPSendError(CHIP_ERROR err, bool isMulticast)
47 // Don't report certain types of routing errors when they occur while sending multicast packets.
48 // These may indicate that the underlying interface doesn't support multicast (e.g. the loopback
49 // interface on linux) or that the selected interface doesn't have an appropriate source address.
52 #if CHIP_SYSTEM_CONFIG_USE_LWIP
53 if (err == System::MapErrorLwIP(ERR_RTE))
57 #endif // CHIP_SYSTEM_CONFIG_USE_LWIP
59 #if CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK
60 if (err == System::MapErrorPOSIX(ENETUNREACH) || err == System::MapErrorPOSIX(EADDRNOTAVAIL))
71 * Checks if error, while sending, is critical enough to report to the application.
73 * @param[in] err The #CHIP_ERROR being checked for criticality.
75 * @return true if the error is NOT critical; false otherwise.
78 bool IsSendErrorNonCritical(CHIP_ERROR err)
80 return (err == INET_ERROR_NOT_IMPLEMENTED || err == INET_ERROR_OUTBOUND_MESSAGE_TRUNCATED ||
81 err == INET_ERROR_MESSAGE_TOO_LONG || err == INET_ERROR_NO_MEMORY || CHIP_CONFIG_IsPlatformErrorNonCritical(err));
84 } // namespace Messaging