Matter SDK Coverage Report
Current view: top level - inet - InetInterface.h (source / functions) Coverage Total Hit
Test: SHA:09f6fdf93a7e847a42518c076e487f336877a722 Lines: 100.0 % 11 11
Test Date: 2025-06-07 07:10:33 Functions: 100.0 % 9 9

            Line data    Source code
       1              : /*
       2              :  *
       3              :  *    Copyright (c) 2020 Project CHIP Authors
       4              :  *    Copyright (c) 2019 Google LLC.
       5              :  *    Copyright (c) 2013-2017 Nest Labs, Inc.
       6              :  *
       7              :  *    Licensed under the Apache License, Version 2.0 (the "License");
       8              :  *    you may not use this file except in compliance with the License.
       9              :  *    You may obtain a copy of the License at
      10              :  *
      11              :  *        http://www.apache.org/licenses/LICENSE-2.0
      12              :  *
      13              :  *    Unless required by applicable law or agreed to in writing, software
      14              :  *    distributed under the License is distributed on an "AS IS" BASIS,
      15              :  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      16              :  *    See the License for the specific language governing permissions and
      17              :  *    limitations under the License.
      18              :  */
      19              : 
      20              : /**
      21              :  * @file
      22              :  *  This file defines the <tt>Inet::InterfaceId</tt> type alias and related
      23              :  *  classes for iterating on the list of system network interfaces and the list
      24              :  *  of system interface addresses.
      25              :  */
      26              : 
      27              : #pragma once
      28              : 
      29              : #include <inet/InetConfig.h>
      30              : 
      31              : #include <inet/IPAddress.h>
      32              : #include <inet/InetError.h>
      33              : #include <lib/support/DLLUtil.h>
      34              : 
      35              : #if CHIP_SYSTEM_CONFIG_USE_LWIP && !CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
      36              : #include <lwip/netif.h>
      37              : #endif // CHIP_SYSTEM_CONFIG_USE_LWIP
      38              : 
      39              : #if CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
      40              : struct if_nameindex;
      41              : struct ifaddrs;
      42              : #endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
      43              : 
      44              : #if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF
      45              : #include <zephyr/device.h>
      46              : 
      47              : struct net_if;
      48              : struct net_if_ipv4;
      49              : struct net_if_ipv6;
      50              : #endif // CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF
      51              : 
      52              : #include <stddef.h>
      53              : #include <stdint.h>
      54              : 
      55              : namespace chip {
      56              : namespace Inet {
      57              : 
      58              : class IPAddress;
      59              : class IPPrefix;
      60              : 
      61              : /**
      62              :  * Data type describing interface type.
      63              :  */
      64              : enum class InterfaceType
      65              : {
      66              :     Unknown  = 0,
      67              :     WiFi     = 1,
      68              :     Ethernet = 2,
      69              :     Cellular = 3,
      70              :     Thread   = 4,
      71              : };
      72              : 
      73              : /**
      74              :  * Indicator for system network interfaces.
      75              :  */
      76              : class InterfaceId
      77              : {
      78              : public:
      79              : #if CHIP_SYSTEM_CONFIG_USE_LWIP && !CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT && !CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
      80              :     using PlatformType                       = struct netif *;
      81              :     static constexpr size_t kMaxIfNameLength = 13; // Names are formatted as %c%c%d
      82              : #endif                                             // CHIP_SYSTEM_CONFIG_USE_LWIP
      83              : 
      84              : #if (CHIP_SYSTEM_CONFIG_USE_SOCKETS || CHIP_SYSTEM_CONFIG_USE_NETWORK_FRAMEWORK) && CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
      85              :     using PlatformType                       = unsigned int;
      86              :     static constexpr size_t kMaxIfNameLength = IF_NAMESIZE;
      87              : #endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
      88              : 
      89              : #if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF
      90              :     using PlatformType                       = int;
      91              :     static constexpr size_t kMaxIfNameLength = Z_DEVICE_MAX_NAME_LEN;
      92              : #endif
      93              : 
      94              : #if CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
      95              :     using PlatformType                       = unsigned int;
      96              :     static constexpr size_t kMaxIfNameLength = 6;
      97              : #endif
      98              : 
      99              :     ~InterfaceId() = default;
     100              : 
     101          267 :     constexpr InterfaceId() : mPlatformInterface(kPlatformNull) {}
     102         1213 :     explicit constexpr InterfaceId(PlatformType interface) : mPlatformInterface(interface) {}
     103              : 
     104         1062 :     constexpr InterfaceId(const InterfaceId & other) : mPlatformInterface(other.mPlatformInterface) {}
     105         3379 :     constexpr InterfaceId & operator=(const InterfaceId & other)
     106              :     {
     107         3379 :         mPlatformInterface = other.mPlatformInterface;
     108         3379 :         return *this;
     109              :     }
     110              : 
     111          183 :     static constexpr InterfaceId Null() { return InterfaceId(); }
     112              : 
     113           28 :     constexpr bool operator==(const InterfaceId & other) const { return mPlatformInterface == other.mPlatformInterface; }
     114        13793 :     constexpr bool operator!=(const InterfaceId & other) const { return mPlatformInterface != other.mPlatformInterface; }
     115              : 
     116              :     /**
     117              :      * Test for inequivalence with the null interface.
     118              :      */
     119        15204 :     bool IsPresent() const { return mPlatformInterface != kPlatformNull; }
     120              : 
     121              :     /**
     122              :      * Get the underlying platform representation of the interface.
     123              :      */
     124          118 :     PlatformType GetPlatformInterface() const { return mPlatformInterface; }
     125              : 
     126              :     /**
     127              :      * Get the name of the network interface
     128              :      *
     129              :      * @param[in]   nameBuf     Region of memory to write the interface name.
     130              :      * @param[in]   nameBufSize Size of the region denoted by \c nameBuf.
     131              :      *
     132              :      * @retval  CHIP_NO_ERROR               Successful result, interface name written.
     133              :      * @retval  CHIP_ERROR_BUFFER_TOO_SMALL Buffer is too small for the interface name.
     134              :      * @retval  other                       Another system or platform error.
     135              :      *
     136              :      *  Writes the name of the network interface as a \c NUL terminated text string at \c nameBuf.
     137              :      *  The name of the unspecified network interface is the empty string.
     138              :      */
     139              :     CHIP_ERROR GetInterfaceName(char * nameBuf, size_t nameBufSize) const;
     140              : 
     141              :     /**
     142              :      * Search the list of network interfaces for the indicated name.
     143              :      *
     144              :      * @param[in]   intfName    Name of the network interface to find.
     145              :      * @param[out]  intfId      Indicator of the network interface to assign.
     146              :      *
     147              :      * @retval  CHIP_NO_ERROR                   Success, network interface indicated.
     148              :      * @retval  INET_ERROR_UNKNOWN_INTERFACE    No network interface found.
     149              :      * @retval  other                           Another system or platform error.
     150              :      *
     151              :      * @note
     152              :      *  On LwIP, this function must be called with the LwIP stack lock acquired.
     153              :      */
     154              :     static CHIP_ERROR InterfaceNameToId(const char * intfName, InterfaceId & intfId);
     155              : 
     156              :     /**
     157              :      *  Get the interface identifier for the specified IP address. If the
     158              :      *  interface identifier cannot be derived it is set to the default InterfaceId.
     159              :      *
     160              :      *  @note
     161              :      *    This function fetches the first interface (from the configured list
     162              :      *    of interfaces) that matches the specified IP address.
     163              :      */
     164              :     static InterfaceId FromIPAddress(const IPAddress & addr);
     165              : 
     166              :     /**
     167              :      *  Check if there is a prefix match between the specified IPv6 address and any of
     168              :      *  the locally configured IPv6 addresses.
     169              :      *
     170              :      *  @param[in]    addr    The IPv6 address to check for the prefix-match.
     171              :      *  @return true if a successful match is found, otherwise false.
     172              :      */
     173              :     static bool MatchLocalIPv6Subnet(const IPAddress & addr);
     174              : 
     175              :     /**
     176              :      *  Get the link local IPv6 address.
     177              :      *
     178              :      *  @param[out]   llAddr  The link local IPv6 address for the link.
     179              :      *
     180              :      *  @retval    #CHIP_ERROR_NOT_IMPLEMENTED      If IPv6 is not supported.
     181              :      *  @retval    #CHIP_ERROR_INVALID_ARGUMENT     If the link local address
     182              :      *                                              is nullptr.
     183              :      *  @retval    #INET_ERROR_ADDRESS_NOT_FOUND    If the link does not have
     184              :      *                                              any address configured
     185              :      *                                              or if no link local (fe80::)
     186              :      *                                              address is present.
     187              :      *  @retval    #CHIP_NO_ERROR                   On success.
     188              :      */
     189              :     CHIP_ERROR GetLinkLocalAddr(IPAddress * llAddr) const;
     190              : 
     191              : private:
     192              : #if CHIP_SYSTEM_CONFIG_USE_LWIP && !CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
     193              :     static constexpr PlatformType kPlatformNull = nullptr;
     194              : #endif // CHIP_SYSTEM_CONFIG_USE_LWIP
     195              : 
     196              : #if CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
     197              :     static constexpr PlatformType kPlatformNull = 0;
     198              : #endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
     199              : 
     200              : #if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF
     201              :     static constexpr PlatformType kPlatformNull = 0;
     202              : #endif
     203              : 
     204              : #if CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
     205              :     static constexpr PlatformType kPlatformNull = 0;
     206              : #endif
     207              : 
     208              :     PlatformType mPlatformInterface;
     209              : };
     210              : 
     211              : /**
     212              :  * Compute a prefix length from a variable-length netmask.
     213              :  */
     214              : extern uint8_t NetmaskToPrefixLength(const uint8_t * netmask, uint16_t netmaskLen);
     215              : 
     216              : /**
     217              :  * @brief   Iterator for the list of system network interfaces.
     218              :  *
     219              :  * @details
     220              :  *  Use objects of this class to iterate the list of system network interfaces.
     221              :  *
     222              :  *  Methods on an individual instance of this class are *not* thread-safe;
     223              :  *  however separate instances may be used simultaneously by multiple threads.
     224              :  *
     225              :  *  On multi-threaded LwIP systems, instances are thread-safe relative to other
     226              :  *  threads accessing the global LwIP state provided that the other threads hold
     227              :  *  the LwIP core lock while mutating the list of netifs, and that netif object
     228              :  *  themselves are never destroyed.
     229              :  *
     230              :  *  On sockets-based systems, iteration is always stable in the face of changes
     231              :  *  to the underlying system's interfaces.
     232              :  *
     233              :  *  On LwIP systems, iteration is stable except in the case where the currently
     234              :  *  selected interface is removed from the list, in which case iteration ends
     235              :  *  immediately.
     236              :  */
     237              : class InterfaceIterator
     238              : {
     239              : public:
     240              :     /**
     241              :      * Constructs an InterfaceIterator object.
     242              :      *
     243              :      *  Starts the iterator at the first network interface. On some platforms,
     244              :      *  this constructor may allocate resources recycled by the destructor.
     245              :      */
     246              :     InterfaceIterator();
     247              :     ~InterfaceIterator();
     248              : 
     249              :     /**
     250              :      * Test whether the iterator is positioned on an interface
     251              :      *
     252              :      * @return  \c true if the iterator is positioned on an interface;
     253              :      *          \c false if positioned beyond the end of the interface list.
     254              :      */
     255              :     bool HasCurrent();
     256              : 
     257              :     /**
     258              :      * Advance the iterator to the next network interface.
     259              :      *
     260              :      * @return  \c false if advanced beyond the end, else \c true.
     261              :      *
     262              :      *  Advances the internal iterator to the next network interface or to a position
     263              :      *  beyond the end of the interface list.
     264              :      *
     265              :      *  On multi-threaded LwIP systems, this method is thread-safe relative to other
     266              :      *  threads accessing the global LwIP state provided that: 1) the other threads
     267              :      *  hold the LwIP core lock while mutating the list of netifs; and 2) netif objects
     268              :      *  themselves are never destroyed.
     269              :      *
     270              :      *  Iteration is stable in the face of changes to the underlying system's
     271              :      *  interfaces, *except* in the case of LwIP systems when the currently selected
     272              :      *  interface is removed from the list, which causes iteration to end immediately.
     273              :      */
     274              :     bool Next();
     275              : 
     276              :     /**
     277              :      * InterfaceId InterfaceIterator::GetInterfaceId(void)
     278              :      *
     279              :      * Returns the network interface id at the current iterator position.
     280              :      *
     281              :      * @retval  id                   The current network interface id.
     282              :      * @retval  InterfaceId()   If advanced beyond the end of the list.
     283              :      */
     284              :     InterfaceId GetInterfaceId();
     285              : 
     286              :     /**
     287              :      * Get the name of the current network interface
     288              :      *
     289              :      * @param[in]   nameBuf     Region of memory to write the interface name.
     290              :      * @param[in]   nameBufSize Size of the region denoted by \c nameBuf.
     291              :      *
     292              :      * @retval  CHIP_NO_ERROR               Successful result, interface name written.
     293              :      * @retval  CHIP_ERROR_INCORRECT_STATE  Iterator is positioned beyond the end of the list.
     294              :      * @retval  CHIP_ERROR_BUFFER_TOO_SMALL Name is too large to be written in buffer.
     295              :      * @retval  other                       Another system or platform error.
     296              :      *
     297              :      *  Writes the name of the network interface as \c NUL terminated text string at \c nameBuf.
     298              :      */
     299              :     CHIP_ERROR GetInterfaceName(char * nameBuf, size_t nameBufSize);
     300              : 
     301              :     /**
     302              :      * Returns whether the current network interface is up.
     303              :      *
     304              :      * @return  \c true if current network interface is up, \c false if not
     305              :      *          or if the iterator is positioned beyond the end of the list.
     306              :      */
     307              :     bool IsUp();
     308              : 
     309              :     /**
     310              :      * Returns whether the current network interface is a loopback interface
     311              :      *
     312              :      * @return  \c true if current network interface is a loopback interface, \c false
     313              :      *          if not, or if the iterator is positioned beyond the end of the list.
     314              :      */
     315              :     bool IsLoopback();
     316              : 
     317              :     /**
     318              :      * Returns whether the current network interface supports multicast.
     319              :      *
     320              :      * @return  \c true if current network interface supports multicast, \c false
     321              :      *          if not, or if the iterator is positioned beyond the end of the list.
     322              :      */
     323              :     bool SupportsMulticast();
     324              : 
     325              :     /**
     326              :      * Returns whether the current network interface has a broadcast address.
     327              :      *
     328              :      * @return  \c true if current network interface has a broadcast address, \c false
     329              :      *          if not, or if the iterator is positioned beyond the end of the list.
     330              :      */
     331              :     bool HasBroadcastAddress();
     332              : 
     333              :     /**
     334              :      * Get the interface type of the current network interface.
     335              :      *
     336              :      * @param[out]   type       Object to save the interface type.
     337              :      */
     338              :     CHIP_ERROR GetInterfaceType(InterfaceType & type);
     339              : 
     340              :     /**
     341              :      * Get the hardware address of the current network interface
     342              :      *
     343              :      * @param[out]   addressBuffer       Region of memory to write the hardware address.
     344              :      * @param[out]   addressSize         Size of the address saved to a buffer.
     345              :      * @param[in]    addressBufferSize   Maximum size of a buffer to save data.
     346              :      */
     347              :     CHIP_ERROR GetHardwareAddress(uint8_t * addressBuffer, uint8_t & addressSize, uint8_t addressBufferSize);
     348              : 
     349              : protected:
     350              : #if CHIP_SYSTEM_CONFIG_USE_LWIP && !CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
     351              :     struct netif * mCurNetif;
     352              : #endif // CHIP_SYSTEM_CONFIG_USE_LWIP
     353              : 
     354              : #if CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
     355              :     struct if_nameindex * mIntfArray;
     356              :     size_t mCurIntf;
     357              :     short mIntfFlags;
     358              :     bool mIntfFlagsCached;
     359              : 
     360              :     short GetFlags();
     361              : #endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
     362              : 
     363              : #if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF
     364              :     InterfaceId::PlatformType mCurrentId = 1;
     365              :     net_if * mCurrentInterface           = nullptr;
     366              : #endif // CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF
     367              : #if CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
     368              :     bool mHasCurrent = true;
     369              : #endif // CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
     370              : };
     371              : 
     372              : /**
     373              :  * @brief   Iterator for the list of system network interface IP addresses.
     374              :  *
     375              :  * @details
     376              :  *  Use objects of this class to iterate the list of system network interface
     377              :  *  interface IP addresses.
     378              :  *
     379              :  *  Methods on an individual instance of this class are *not* thread-safe;
     380              :  *  however separate instances may be used simultaneously by multiple threads.
     381              :  *
     382              :  *  On multi-threaded LwIP systems, instances are thread-safe relative to other
     383              :  *  threads accessing the global LwIP state provided that: 1) other threads hold
     384              :  *  the LwIP core lock while mutating the list of netifs; and 2) netif object
     385              :  *  themselves are never destroyed.
     386              :  *
     387              :  *  On sockets-based systems, iteration is always stable in the face of changes
     388              :  *  to the underlying system's interfaces and/or addresses.
     389              :  *
     390              :  *  On LwIP systems, iteration is stable except in the case where the interface
     391              :  *  associated with the current address is removed, in which case iteration may
     392              :  *  end prematurely.
     393              :  */
     394              : class DLL_EXPORT InterfaceAddressIterator
     395              : {
     396              : public:
     397              :     /**
     398              :      * Constructs an InterfaceAddressIterator object.
     399              :      *
     400              :      *  Starts the iterator at the first network address. On some platforms,
     401              :      *  this constructor may allocate resources recycled by the destructor.
     402              :      */
     403              :     InterfaceAddressIterator();
     404              : 
     405              :     /**
     406              :      * Destroys an InterfaceAddressIterator object.
     407              :      *
     408              :      *  Recycles any resources allocated by the constructor.
     409              :      */
     410              :     ~InterfaceAddressIterator();
     411              : 
     412              :     /**
     413              :      * Test whether the iterator is positioned on an interface address
     414              :      *
     415              :      * @return  \c true if the iterator is positioned on an interface address;
     416              :      *          \c false if positioned beyond the end of the address list.
     417              :      */
     418              :     bool HasCurrent();
     419              : 
     420              :     /**
     421              :      * @fn      bool InterfaceAddressIterator::Next(void)
     422              :      *
     423              :      * @brief   Advance the iterator to the next interface address.
     424              :      *
     425              :      * @return  \c false if advanced beyond the end, else \c true.
     426              :      *
     427              :      * @details
     428              :      *     Advances the iterator to the next interface address or to a position
     429              :      *     beyond the end of the address list.
     430              :      *
     431              :      *     On LwIP, this method is thread-safe provided that: 1) other threads hold
     432              :      *     the LwIP core lock while mutating the netif list; and 2) netif objects
     433              :      *     themselves are never destroyed.  Additionally, iteration on LwIP systems
     434              :      *     will terminate early if the current interface is removed from the list.
     435              :      */
     436              :     bool Next();
     437              : 
     438              :     /**
     439              :      * @fn      IPAddress InterfaceAddressIterator::GetAddress(void)
     440              :      *
     441              :      * @brief   Get the current interface address.
     442              :      *
     443              :      * @param[out] outIPAddress     The current interface address
     444              :      *
     445              :      * @return CHIP_NO_ERROR        if the result IPAddress is valid.
     446              :      * @return CHIP_ERROR_SENTINEL  if the iterator is positioned beyond the end of the address list.
     447              :      * @return other error from lower-level code
     448              :      */
     449              :     CHIP_ERROR GetAddress(IPAddress & outIPAddress);
     450              : 
     451              :     /**
     452              :      * @fn      uint8_t InterfaceAddressIterator::GetPrefixLength(void)
     453              :      *
     454              :      * @brief   Gets the network prefix associated with the current interface address.
     455              :      *
     456              :      * @return  the network prefix (in bits) or 0 if the iterator is positioned beyond
     457              :      *          the end of the address list.
     458              :      *
     459              :      * @details
     460              :      *     On LwIP, this method simply returns the hard-coded constant 64.
     461              :      *
     462              :      *     Note Well: the standard subnet prefix on all links other than PPP
     463              :      *     links is 64 bits. On PPP links and some non-broadcast multipoint access
     464              :      *     links, the convention is either 127 bits or 128 bits, but it might be
     465              :      *     something else. On most platforms, the system's interface address
     466              :      *     structure can represent arbitrary prefix lengths between 0 and 128.
     467              :      */
     468              :     uint8_t GetPrefixLength();
     469              : 
     470              :     /**
     471              :      * @fn      InterfaceId InterfaceAddressIterator::GetInterfaceId(void)
     472              :      *
     473              :      * @brief   Returns the network interface id associated with the current
     474              :      *          interface address.
     475              :      *
     476              :      * @return  the interface id or \c InterfaceId() if the iterator
     477              :      *          is positioned beyond the end of the address list.
     478              :      */
     479              :     InterfaceId GetInterfaceId();
     480              : 
     481              :     /**
     482              :      * @fn      CHIP_ERROR InterfaceAddressIterator::GetInterfaceName(char * nameBuf, size_t nameBufSize)
     483              :      *
     484              :      * @brief   Get the name of the network interface associated with the
     485              :      *          current interface address.
     486              :      *
     487              :      * @param[in]   nameBuf     region of memory to write the interface name
     488              :      * @param[in]   nameBufSize size of the region denoted by \c nameBuf
     489              :      *
     490              :      * @retval  CHIP_NO_ERROR           successful result, interface name written
     491              :      * @retval  CHIP_ERROR_BUFFER_TOO_SMALL    name is too large to be written in buffer
     492              :      * @retval  CHIP_ERROR_INCORRECT_STATE
     493              :      *                                  the iterator is not currently positioned on an
     494              :      *                                  interface address
     495              :      * @retval  other                   another system or platform error
     496              :      *
     497              :      * @details
     498              :      *     Writes the name of the network interface as \c NUL terminated text string
     499              :      *     at \c nameBuf.
     500              :      */
     501              :     CHIP_ERROR GetInterfaceName(char * nameBuf, size_t nameBufSize);
     502              : 
     503              :     /**
     504              :      * Returns whether the network interface associated with the current interface address is up.
     505              :      *
     506              :      * @return  \c true if current network interface is up, \c false if not, or
     507              :      *          if the iterator is not positioned on an interface address.
     508              :      */
     509              :     bool IsUp();
     510              : 
     511              :     /**
     512              :      * Returns whether the current network interface is a loopback interface
     513              :      *
     514              :      * @return  \c true if current network interface is a loopback interface, \c false
     515              :      *          if not, or if the iterator is positioned beyond the end of the list.
     516              :      */
     517              :     bool IsLoopback();
     518              : 
     519              :     /**
     520              :      * Returns whether the network interface associated with the current interface address supports multicast.
     521              :      *
     522              :      * @return  \c true if multicast is supported, \c false if not, or
     523              :      *          if the iterator is not positioned on an interface address.
     524              :      */
     525              :     bool SupportsMulticast();
     526              : 
     527              :     /**
     528              :      * Returns whether the network interface associated with the current interface address has an IPv4 broadcast address.
     529              :      *
     530              :      * @return  \c true if the interface has a broadcast address, \c false if not, or
     531              :      *          if the iterator is not positioned on an interface address.
     532              :      */
     533              :     bool HasBroadcastAddress();
     534              : 
     535              : private:
     536              : #if CHIP_SYSTEM_CONFIG_USE_LWIP && !CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
     537              :     enum
     538              :     {
     539              :         kBeforeStartIndex = -1
     540              :     };
     541              : 
     542              :     InterfaceIterator mIntfIter;
     543              :     int mCurAddrIndex;
     544              : #endif // CHIP_SYSTEM_CONFIG_USE_LWIP
     545              : 
     546              : #if CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
     547              :     struct ifaddrs * mAddrsList;
     548              :     struct ifaddrs * mCurAddr;
     549              : #endif // CHIP_SYSTEM_CONFIG_USE_BSD_IFADDRS
     550              : 
     551              : #if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF
     552              :     InterfaceIterator mIntfIter;
     553              :     net_if_ipv6 * mIpv6 = nullptr;
     554              :     int mCurAddrIndex   = -1;
     555              : #endif // CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF
     556              : #if CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
     557              :     const otNetifAddress * mNetifAddrList;
     558              :     const otNetifAddress * mCurAddr;
     559              : #endif // #if CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
     560              : };
     561              : 
     562              : #if CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
     563              : inline InterfaceIterator::InterfaceIterator(void) {}
     564              : inline InterfaceIterator::~InterfaceIterator()               = default;
     565              : inline InterfaceAddressIterator::~InterfaceAddressIterator() = default;
     566              : inline bool InterfaceIterator::HasCurrent(void)
     567              : {
     568              :     return mHasCurrent;
     569              : }
     570              : #endif
     571              : 
     572              : #if CHIP_SYSTEM_CONFIG_USE_LWIP && !CHIP_SYSTEM_CONFIG_USE_OPENTHREAD_ENDPOINT
     573              : 
     574              : inline InterfaceIterator::InterfaceIterator(void)
     575              : {
     576              :     mCurNetif = netif_list;
     577              : }
     578              : 
     579              : inline InterfaceIterator::~InterfaceIterator(void) {}
     580              : 
     581              : inline bool InterfaceIterator::HasCurrent(void)
     582              : {
     583              :     return mCurNetif != NULL;
     584              : }
     585              : 
     586              : inline InterfaceId InterfaceIterator::GetInterfaceId(void)
     587              : {
     588              :     return InterfaceId(mCurNetif);
     589              : }
     590              : 
     591              : inline InterfaceAddressIterator::InterfaceAddressIterator(void)
     592              : {
     593              :     mCurAddrIndex = kBeforeStartIndex;
     594              : }
     595              : 
     596              : inline InterfaceAddressIterator::~InterfaceAddressIterator(void) {}
     597              : 
     598              : #endif // CHIP_SYSTEM_CONFIG_USE_LWIP
     599              : 
     600              : #if CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF
     601              : inline InterfaceIterator::~InterfaceIterator()               = default;
     602              : inline InterfaceAddressIterator::~InterfaceAddressIterator() = default;
     603              : #endif // CHIP_SYSTEM_CONFIG_USE_ZEPHYR_NET_IF
     604              : 
     605              : } // namespace Inet
     606              : } // namespace chip
        

Generated by: LCOV version 2.0-1