mirror of
https://github.com/espressif/openthread.git
synced 2026-09-08 10:10:06 +00:00
[posix] add a method to get the infra interface name (#7300)
When setting the IP forwarding rule on Android platform, it needs to specify the two interfaces between which IP forwarding is enabled. This commit adds a method to get the infra interface name for setting IP forwarding rule.
This commit is contained in:
@@ -176,6 +176,14 @@ const char *otSysGetThreadNetifName(void);
|
||||
*/
|
||||
unsigned int otSysGetThreadNetifIndex(void);
|
||||
|
||||
/**
|
||||
* This method returns the infrastructure network interface name.
|
||||
*
|
||||
* @returns The infrastructure network interface name, or `nullptr` if not specified.
|
||||
*
|
||||
*/
|
||||
const char *otSysGetInfraNetifName(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
} // end of extern "C"
|
||||
#endif
|
||||
|
||||
@@ -101,6 +101,11 @@ bool platformInfraIfIsRunning(void)
|
||||
return ot::Posix::InfraNetif::Get().IsRunning();
|
||||
}
|
||||
|
||||
const char *otSysGetInfraNetifName(void)
|
||||
{
|
||||
return ot::Posix::InfraNetif::Get().GetNetifName();
|
||||
}
|
||||
|
||||
namespace ot {
|
||||
namespace Posix {
|
||||
namespace {
|
||||
|
||||
@@ -128,10 +128,20 @@ public:
|
||||
const otIp6Address &aDestAddress,
|
||||
const uint8_t * aBuffer,
|
||||
uint16_t aBufferLength);
|
||||
|
||||
/**
|
||||
* This method gets the infrastructure network interface name.
|
||||
*
|
||||
* @returns The infrastructure network interface name, or `nullptr` if not specified.
|
||||
*
|
||||
*/
|
||||
const char *GetNetifName(void) const { return (mInfraIfIndex != 0) ? mInfraIfName : nullptr; }
|
||||
|
||||
/**
|
||||
* This function gets the infrastructure network interface singleton.
|
||||
*
|
||||
* @returns The singleton object.
|
||||
*
|
||||
*/
|
||||
static InfraNetif &Get(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user