mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-08-25 07:33:11 +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
|
#if LWIP_SOCKET
|
||||||
|
|
||||||
#include "lwip/if.h"
|
#include "lwip/if_api.h"
|
||||||
#include "lwip/netifapi.h"
|
#include "lwip/netifapi.h"
|
||||||
|
|
||||||
char *
|
char *
|
||||||
|
@ -269,8 +269,8 @@ netifapi_netif_name_to_index(const char *name, u8_t *idx)
|
|||||||
*idx = 0;
|
*idx = 0;
|
||||||
|
|
||||||
#if LWIP_MPU_COMPATIBLE
|
#if LWIP_MPU_COMPATIBLE
|
||||||
strncpy(NETIFAPI_VAR_REF(msg).msg.ifs.name, name, IF_NAMESIZE - 1);
|
strncpy(NETIFAPI_VAR_REF(msg).msg.ifs.name, name, NETIF_NAMESIZE - 1);
|
||||||
NETIFAPI_VAR_REF(msg).msg.ifs.name[IF_NAMESIZE - 1] = '\0';
|
NETIFAPI_VAR_REF(msg).msg.ifs.name[NETIF_NAMESIZE - 1] = '\0';
|
||||||
#else
|
#else
|
||||||
NETIFAPI_VAR_REF(msg).msg.ifs.name = LWIP_CONST_CAST(char*, name);
|
NETIFAPI_VAR_REF(msg).msg.ifs.name = LWIP_CONST_CAST(char*, name);
|
||||||
#endif /* LWIP_MPU_COMPATIBLE */
|
#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 idx the interface index of the netif
|
||||||
* @param name output name of the found netif, empty '\0' string if netif not found.
|
* @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
|
err_t
|
||||||
netifapi_netif_index_to_name(u8_t idx, char *name)
|
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);
|
err = tcpip_api_call(netifapi_do_index_to_name, &API_VAR_REF(msg).call);
|
||||||
#if LWIP_MPU_COMPATIBLE
|
#if LWIP_MPU_COMPATIBLE
|
||||||
if (!err) {
|
if (!err) {
|
||||||
strncpy(name, NETIFAPI_VAR_REF(msg).msg.ifs.name, IF_NAMESIZE - 1);
|
strncpy(name, NETIFAPI_VAR_REF(msg).msg.ifs.name, NETIF_NAMESIZE - 1);
|
||||||
name[IF_NAMESIZE - 1] = '\0';
|
name[NETIF_NAMESIZE - 1] = '\0';
|
||||||
}
|
}
|
||||||
#endif /* LWIP_MPU_COMPATIBLE */
|
#endif /* LWIP_MPU_COMPATIBLE */
|
||||||
NETIFAPI_VAR_FREE(msg);
|
NETIFAPI_VAR_FREE(msg);
|
||||||
|
@ -65,7 +65,6 @@
|
|||||||
#include "lwip/stats.h"
|
#include "lwip/stats.h"
|
||||||
#include "lwip/sys.h"
|
#include "lwip/sys.h"
|
||||||
#include "lwip/ip.h"
|
#include "lwip/ip.h"
|
||||||
#include "lwip/if.h"
|
|
||||||
#if ENABLE_LOOPBACK
|
#if ENABLE_LOOPBACK
|
||||||
#if LWIP_NETIF_LOOPBACK_MULTITHREADING
|
#if LWIP_NETIF_LOOPBACK_MULTITHREADING
|
||||||
#include "lwip/tcpip.h"
|
#include "lwip/tcpip.h"
|
||||||
@ -1322,7 +1321,7 @@ netif_name_to_index(const char *name)
|
|||||||
* or NULL if not found/on error
|
* or NULL if not found/on error
|
||||||
*
|
*
|
||||||
* @param idx the interface index of the netif
|
* @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 *
|
char *
|
||||||
netif_index_to_name(u8_t idx, char *name)
|
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) {
|
if (curif->num == num) {
|
||||||
name[0] = curif->name[0];
|
name[0] = curif->name[0];
|
||||||
name[1] = curif->name[1];
|
name[1] = curif->name[1];
|
||||||
lwip_itoa(&name[2], IF_NAMESIZE - 2, num);
|
lwip_itoa(&name[2], NETIF_NAMESIZE - 2, num);
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
curif = curif->next;
|
curif = curif->next;
|
||||||
|
@ -40,8 +40,9 @@
|
|||||||
#define LWIP_HDR_IF_H
|
#define LWIP_HDR_IF_H
|
||||||
|
|
||||||
#include "lwip/opt.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);
|
char * lwip_if_indextoname(unsigned int ifindex, char *ifname);
|
||||||
unsigned int lwip_if_nametoindex(const char *ifname);
|
unsigned int lwip_if_nametoindex(const char *ifname);
|
@ -63,6 +63,12 @@ extern "C" {
|
|||||||
#define NETIF_MAX_HWADDR_LEN 6U
|
#define NETIF_MAX_HWADDR_LEN 6U
|
||||||
#endif
|
#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
|
* @defgroup netif_flags Flags
|
||||||
* @ingroup netif
|
* @ingroup netif
|
||||||
|
@ -40,7 +40,6 @@
|
|||||||
#include "lwip/netif.h"
|
#include "lwip/netif.h"
|
||||||
#include "lwip/dhcp.h"
|
#include "lwip/dhcp.h"
|
||||||
#include "lwip/autoip.h"
|
#include "lwip/autoip.h"
|
||||||
#include "lwip/if.h"
|
|
||||||
#include "lwip/priv/tcpip_priv.h"
|
#include "lwip/priv/tcpip_priv.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@ -76,7 +75,7 @@ struct netifapi_msg {
|
|||||||
} common;
|
} common;
|
||||||
struct {
|
struct {
|
||||||
#if LWIP_MPU_COMPATIBLE
|
#if LWIP_MPU_COMPATIBLE
|
||||||
char name[IF_NAMESIZE];
|
char name[NETIF_NAMESIZE];
|
||||||
#else /* LWIP_MPU_COMPATIBLE */
|
#else /* LWIP_MPU_COMPATIBLE */
|
||||||
char *name;
|
char *name;
|
||||||
#endif /* LWIP_MPU_COMPATIBLE */
|
#endif /* LWIP_MPU_COMPATIBLE */
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* @file
|
* @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…
Reference in New Issue
Block a user