未验证 提交 c2f23fd1 编写于 作者: B Bernard Xiong 提交者: GitHub

Merge pull request #3278 from xiangxistu/master

[net][lwip] add personalized RT-Thread sign into lwip protocol stack
......@@ -499,6 +499,14 @@
/* no read/write/close for socket */
#define LWIP_POSIX_SOCKETS_IO_NAMES 0
/**
* LWIP_NETIF_HOSTNAME==1: Support netif hostname
*/
#ifndef LWIP_NETIF_HOSTNAME
#define LWIP_NETIF_HOSTNAME 1
#endif
#define LWIP_NETIF_API 1
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. */
......
......@@ -440,8 +440,13 @@ static err_t eth_netif_device_init(struct netif *netif)
rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flags)
{
struct netif* netif;
#if LWIP_NETIF_HOSTNAME
#define LWIP_HOSTNAME_LEN 16
char *hostname = RT_NULL;
netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN);
#else
netif = (struct netif*) rt_malloc (sizeof(struct netif));
#endif
if (netif == RT_NULL)
{
rt_kprintf("malloc netif failed\n");
......@@ -476,6 +481,13 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
netif->output = etharp_output;
netif->linkoutput = ethernetif_linkoutput;
#if LWIP_NETIF_HOSTNAME
/* Initialize interface hostname */
hostname = (char *)netif + sizeof(struct netif);
rt_sprintf(hostname, "rtthread_%02x%02x", name[0], name[1]);
netif->hostname = hostname;
#endif /* LWIP_NETIF_HOSTNAME */
/* if tcp thread has been started up, we add this netif to the system */
if (rt_thread_find("tcpip") != RT_NULL)
{
......
......@@ -531,6 +531,13 @@
#define LWIP_TCP_KEEPALIVE 1
#endif
/**
* LWIP_NETIF_HOSTNAME==1: Support netif hostname
*/
#ifndef LWIP_NETIF_HOSTNAME
#define LWIP_NETIF_HOSTNAME 1
#endif
/**
* LWIP_NETIF_API==1: Support netif api (in netifapi.c)
*/
......
......@@ -481,8 +481,13 @@ static err_t eth_netif_device_init(struct netif *netif)
rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flags)
{
struct netif* netif;
#if LWIP_NETIF_HOSTNAME
#define LWIP_HOSTNAME_LEN 16
char *hostname = RT_NULL;
netif = (struct netif*) rt_malloc (sizeof(struct netif) + LWIP_HOSTNAME_LEN);
#else
netif = (struct netif*) rt_malloc (sizeof(struct netif));
#endif
if (netif == RT_NULL)
{
rt_kprintf("malloc netif failed\n");
......@@ -519,7 +524,9 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
#if LWIP_NETIF_HOSTNAME
/* Initialize interface hostname */
netif->hostname = "rtthread";
hostname = (char *)netif + sizeof(struct netif);
rt_sprintf(hostname, "rtthread_%02x%02x", name[0], name[1]);
netif->hostname = hostname;
#endif /* LWIP_NETIF_HOSTNAME */
/* if tcp thread has been started up, we add this netif to the system */
......
......@@ -538,6 +538,13 @@
#define LWIP_TCP_KEEPALIVE 1
#endif
/**
* LWIP_NETIF_HOSTNAME==1: Support netif hostname
*/
#ifndef LWIP_NETIF_HOSTNAME
#define LWIP_NETIF_HOSTNAME 1
#endif
/**
* LWIP_NETIF_API==1: Support netif api (in netifapi.c)
*/
......
......@@ -524,7 +524,9 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
#if LWIP_NETIF_HOSTNAME
/* Initialize interface hostname */
netif->hostname = "rtthread";
hostname = (char *)netif + sizeof(struct netif);
rt_sprintf(hostname, "rtthread_%02x%02x", name[0], name[1]);
netif->hostname = hostname;
#endif /* LWIP_NETIF_HOSTNAME */
/* if tcp thread has been started up, we add this netif to the system */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册