mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-04-17 02:42:29 +00:00
task #14314: include cleanups
Couple of more cleanups for task #14314 involving includes: 1) if.h name should match if_api.c due to LwIP convention and history. Standard if.h include can be used with compatibility header in posix/net/if.h 2) API header (if.h) should not be included in core code. This include has been eliminated by moving the definition of IF_NAMESIZE to netif.h as NETIF_NAMESIZE. This is now the canonical definition and IF_NAMESIZE just maps to it to provide the standard type
This commit is contained in:
parent
3d80e51b2a
commit
4fb7d74165
@ -40,7 +40,7 @@
|
||||
|
||||
#if LWIP_SOCKET
|
||||
|
||||
#include "lwip/if.h"
|
||||
#include "lwip/if_api.h"
|
||||
#include "lwip/netifapi.h"
|
||||
|
||||
char *
|
||||
|
@ -269,8 +269,8 @@ netifapi_netif_name_to_index(const char *name, u8_t *idx)
|
||||
*idx = 0;
|
||||
|
||||
#if LWIP_MPU_COMPATIBLE
|
||||
strncpy(NETIFAPI_VAR_REF(msg).msg.ifs.name, name, IF_NAMESIZE - 1);
|
||||
NETIFAPI_VAR_REF(msg).msg.ifs.name[IF_NAMESIZE - 1] = '\0';
|
||||
strncpy(NETIFAPI_VAR_REF(msg).msg.ifs.name, name, NETIF_NAMESIZE - 1);
|
||||
NETIFAPI_VAR_REF(msg).msg.ifs.name[NETIF_NAMESIZE - 1] = '\0';
|
||||
#else
|
||||
NETIFAPI_VAR_REF(msg).msg.ifs.name = LWIP_CONST_CAST(char*, name);
|
||||
#endif /* LWIP_MPU_COMPATIBLE */
|
||||
@ -289,7 +289,7 @@ netifapi_netif_name_to_index(const char *name, u8_t *idx)
|
||||
*
|
||||
* @param idx the interface index of the netif
|
||||
* @param name output name of the found netif, empty '\0' string if netif not found.
|
||||
* name should be of at least IF_NAMESIZE bytes
|
||||
* name should be of at least NETIF_NAMESIZE bytes
|
||||
*/
|
||||
err_t
|
||||
netifapi_netif_index_to_name(u8_t idx, char *name)
|
||||
@ -305,8 +305,8 @@ netifapi_netif_index_to_name(u8_t idx, char *name)
|
||||
err = tcpip_api_call(netifapi_do_index_to_name, &API_VAR_REF(msg).call);
|
||||
#if LWIP_MPU_COMPATIBLE
|
||||
if (!err) {
|
||||
strncpy(name, NETIFAPI_VAR_REF(msg).msg.ifs.name, IF_NAMESIZE - 1);
|
||||
name[IF_NAMESIZE - 1] = '\0';
|
||||
strncpy(name, NETIFAPI_VAR_REF(msg).msg.ifs.name, NETIF_NAMESIZE - 1);
|
||||
name[NETIF_NAMESIZE - 1] = '\0';
|
||||
}
|
||||
#endif /* LWIP_MPU_COMPATIBLE */
|
||||
NETIFAPI_VAR_FREE(msg);
|
||||
|
@ -65,7 +65,6 @@
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/ip.h"
|
||||
#include "lwip/if.h"
|
||||
#if ENABLE_LOOPBACK
|
||||
#if LWIP_NETIF_LOOPBACK_MULTITHREADING
|
||||
#include "lwip/tcpip.h"
|
||||
@ -1322,7 +1321,7 @@ netif_name_to_index(const char *name)
|
||||
* or NULL if not found/on error
|
||||
*
|
||||
* @param idx the interface index of the netif
|
||||
* @param name char buffer of at least IF_NAMESIZE bytes
|
||||
* @param name char buffer of at least NETIF_NAMESIZE bytes
|
||||
*/
|
||||
char *
|
||||
netif_index_to_name(u8_t idx, char *name)
|
||||
@ -1339,7 +1338,7 @@ netif_index_to_name(u8_t idx, char *name)
|
||||
if (curif->num == num) {
|
||||
name[0] = curif->name[0];
|
||||
name[1] = curif->name[1];
|
||||
lwip_itoa(&name[2], IF_NAMESIZE - 2, num);
|
||||
lwip_itoa(&name[2], NETIF_NAMESIZE - 2, num);
|
||||
return name;
|
||||
}
|
||||
curif = curif->next;
|
||||
|
@ -40,8 +40,9 @@
|
||||
#define LWIP_HDR_IF_H
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
#define IF_NAMESIZE 6 /* 2 chars, 3 nums, 1 \0 */
|
||||
#define IF_NAMESIZE NETIF_NAMESIZE
|
||||
|
||||
char * lwip_if_indextoname(unsigned int ifindex, char *ifname);
|
||||
unsigned int lwip_if_nametoindex(const char *ifname);
|
@ -63,6 +63,12 @@ extern "C" {
|
||||
#define NETIF_MAX_HWADDR_LEN 6U
|
||||
#endif
|
||||
|
||||
/** The size of a fully constructed netif name which the
|
||||
* netif can be identified by in APIs. Composed of
|
||||
* 2 chars, 3 (max) digits, and 1 \0
|
||||
*/
|
||||
#define NETIF_NAMESIZE 6
|
||||
|
||||
/**
|
||||
* @defgroup netif_flags Flags
|
||||
* @ingroup netif
|
||||
|
@ -40,7 +40,6 @@
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/dhcp.h"
|
||||
#include "lwip/autoip.h"
|
||||
#include "lwip/if.h"
|
||||
#include "lwip/priv/tcpip_priv.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
@ -76,7 +75,7 @@ struct netifapi_msg {
|
||||
} common;
|
||||
struct {
|
||||
#if LWIP_MPU_COMPATIBLE
|
||||
char name[IF_NAMESIZE];
|
||||
char name[NETIF_NAMESIZE];
|
||||
#else /* LWIP_MPU_COMPATIBLE */
|
||||
char *name;
|
||||
#endif /* LWIP_MPU_COMPATIBLE */
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* @file
|
||||
* This file is a posix wrapper for lwip/if.h.
|
||||
* This file is a posix wrapper for lwip/if_api.h.
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -30,4 +30,4 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include "lwip/if.h"
|
||||
#include "lwip/if_api.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user