[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:
Zhanglong Xia
2022-01-11 13:44:22 -08:00
committed by GitHub
parent 55af6ce2c8
commit 224dd27dbd
3 changed files with 23 additions and 0 deletions
@@ -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
+5
View File
@@ -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 {
+10
View File
@@ -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);