mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-24 15:16:02 +00:00
Also base netif_index_to_name function on netif_get_by_index
This commit is contained in:
parent
d4d8fd819d
commit
400c41ffd9
|
@ -1327,23 +1327,14 @@ netif_name_to_index(const char *name)
|
||||||
char *
|
char *
|
||||||
netif_index_to_name(u8_t idx, char *name)
|
netif_index_to_name(u8_t idx, char *name)
|
||||||
{
|
{
|
||||||
struct netif *curif = netif_list;
|
struct netif *netif = netif_get_by_index(idx);
|
||||||
u8_t num;
|
|
||||||
if (idx == 0) {
|
|
||||||
return NULL; /* indexes start at 1 */
|
|
||||||
}
|
|
||||||
num = netif_index_to_num(idx);
|
|
||||||
|
|
||||||
/* find netif from num */
|
if (netif != NULL) {
|
||||||
while (curif != NULL) {
|
name[0] = netif->name[0];
|
||||||
if (curif->num == num) {
|
name[1] = netif->name[1];
|
||||||
name[0] = curif->name[0];
|
lwip_itoa(&name[2], NETIF_NAMESIZE - 2, netif_index_to_num(idx));
|
||||||
name[1] = curif->name[1];
|
|
||||||
lwip_itoa(&name[2], NETIF_NAMESIZE - 2, num);
|
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
curif = curif->next;
|
|
||||||
}
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1351,16 +1342,16 @@ netif_index_to_name(u8_t idx, char *name)
|
||||||
* @ingroup netif
|
* @ingroup netif
|
||||||
* Return the interface for the netif index
|
* Return the interface for the netif index
|
||||||
*
|
*
|
||||||
* @param index index of netif to find
|
* @param idx index of netif to find
|
||||||
*/
|
*/
|
||||||
struct netif*
|
struct netif*
|
||||||
netif_get_by_index(u8_t index)
|
netif_get_by_index(u8_t idx)
|
||||||
{
|
{
|
||||||
struct netif* netif;
|
struct netif* netif;
|
||||||
|
|
||||||
if (index != NETIF_NO_INDEX) {
|
if (idx != NETIF_NO_INDEX) {
|
||||||
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
for (netif = netif_list; netif != NULL; netif = netif->next) {
|
||||||
if (index == netif_get_index(netif)) {
|
if (idx == netif_get_index(netif)) {
|
||||||
return netif; /* found! */
|
return netif; /* found! */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -499,7 +499,7 @@ err_t netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t
|
||||||
|
|
||||||
u8_t netif_name_to_index(const char *name);
|
u8_t netif_name_to_index(const char *name);
|
||||||
char * netif_index_to_name(u8_t idx, char *name);
|
char * netif_index_to_name(u8_t idx, char *name);
|
||||||
struct netif* netif_get_by_index(u8_t index);
|
struct netif* netif_get_by_index(u8_t idx);
|
||||||
|
|
||||||
/* Interface indexes always start at 1 per RFC 3493, section 4, num starts at 0 */
|
/* Interface indexes always start at 1 per RFC 3493, section 4, num starts at 0 */
|
||||||
#define netif_get_index(netif) ((netif)->num + 1)
|
#define netif_get_index(netif) ((netif)->num + 1)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user