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

Merge pull request #3278 from xiangxistu/master

[net][lwip] add personalized RT-Thread sign into lwip protocol stack
...@@ -264,8 +264,8 @@ ...@@ -264,8 +264,8 @@
#endif #endif
/* /*
* You can re-define following setting in rtcofnig.h to overwrite the default * You can re-define following setting in rtcofnig.h to overwrite the default
* setting in the lwip opts.h * setting in the lwip opts.h
*/ */
/* MEMP_NUM_NETBUF: the number of struct netbufs. */ /* MEMP_NUM_NETBUF: the number of struct netbufs. */
// #define MEMP_NUM_NETBUF 2 // #define MEMP_NUM_NETBUF 2
...@@ -499,6 +499,14 @@ ...@@ -499,6 +499,14 @@
/* no read/write/close for socket */ /* no read/write/close for socket */
#define LWIP_POSIX_SOCKETS_IO_NAMES 0 #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 #define LWIP_NETIF_API 1
/* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. */ /* MEMP_NUM_SYS_TIMEOUT: the number of simulateously active timeouts. */
......
...@@ -165,7 +165,7 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled) ...@@ -165,7 +165,7 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled)
extern int lwip_ping_recv(int s, int *ttl); extern int lwip_ping_recv(int s, int *ttl);
extern err_t lwip_ping_send(int s, ip_addr_t *addr, int size); extern err_t lwip_ping_send(int s, ip_addr_t *addr, int size);
int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len, int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
uint32_t timeout, struct netdev_ping_resp *ping_resp) uint32_t timeout, struct netdev_ping_resp *ping_resp)
{ {
int s, ttl, recv_len, result = 0; int s, ttl, recv_len, result = 0;
...@@ -180,7 +180,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len, ...@@ -180,7 +180,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
struct addrinfo hint, *res = RT_NULL; struct addrinfo hint, *res = RT_NULL;
struct sockaddr_in *h = RT_NULL; struct sockaddr_in *h = RT_NULL;
struct in_addr ina; struct in_addr ina;
RT_ASSERT(netif); RT_ASSERT(netif);
RT_ASSERT(host); RT_ASSERT(host);
RT_ASSERT(ping_resp); RT_ASSERT(ping_resp);
...@@ -199,7 +199,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len, ...@@ -199,7 +199,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
return -RT_ERROR; return -RT_ERROR;
} }
rt_memcpy(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t)); rt_memcpy(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t));
/* new a socket */ /* new a socket */
if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0) if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0)
{ {
...@@ -267,7 +267,7 @@ const struct netdev_ops lwip_netdev_ops = ...@@ -267,7 +267,7 @@ const struct netdev_ops lwip_netdev_ops =
lwip_netdev_set_addr_info, lwip_netdev_set_addr_info,
#ifdef RT_LWIP_DNS #ifdef RT_LWIP_DNS
lwip_netdev_set_dns_server, lwip_netdev_set_dns_server,
#else #else
NULL, NULL,
#endif /* RT_LWIP_DNS */ #endif /* RT_LWIP_DNS */
...@@ -315,7 +315,7 @@ static int netdev_add(struct netif *lwip_netif) ...@@ -315,7 +315,7 @@ static int netdev_add(struct netif *lwip_netif)
rt_strncpy(name, lwip_netif->name, LWIP_NETIF_NAME_LEN); rt_strncpy(name, lwip_netif->name, LWIP_NETIF_NAME_LEN);
result = netdev_register(netdev, name, (void *)lwip_netif); result = netdev_register(netdev, name, (void *)lwip_netif);
/* Update netdev info after registered */ /* Update netdev info after registered */
netdev->flags = lwip_netif->flags; netdev->flags = lwip_netif->flags;
netdev->mtu = lwip_netif->mtu; netdev->mtu = lwip_netif->mtu;
...@@ -325,7 +325,7 @@ static int netdev_add(struct netif *lwip_netif) ...@@ -325,7 +325,7 @@ static int netdev_add(struct netif *lwip_netif)
netdev->ip_addr = lwip_netif->ip_addr; netdev->ip_addr = lwip_netif->ip_addr;
netdev->gw = lwip_netif->gw; netdev->gw = lwip_netif->gw;
netdev->netmask = lwip_netif->netmask; netdev->netmask = lwip_netif->netmask;
#ifdef RT_LWIP_DHCP #ifdef RT_LWIP_DHCP
netdev_low_level_set_dhcp_status(netdev, RT_TRUE); netdev_low_level_set_dhcp_status(netdev, RT_TRUE);
#endif #endif
...@@ -440,8 +440,13 @@ static err_t eth_netif_device_init(struct netif *netif) ...@@ -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) rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flags)
{ {
struct netif* netif; 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)); netif = (struct netif*) rt_malloc (sizeof(struct netif));
#endif
if (netif == RT_NULL) if (netif == RT_NULL)
{ {
rt_kprintf("malloc netif failed\n"); 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_ ...@@ -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->output = etharp_output;
netif->linkoutput = ethernetif_linkoutput; 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 tcp thread has been started up, we add this netif to the system */
if (rt_thread_find("tcpip") != RT_NULL) if (rt_thread_find("tcpip") != RT_NULL)
{ {
...@@ -630,7 +642,7 @@ static void eth_rx_thread_entry(void* parameter) ...@@ -630,7 +642,7 @@ static void eth_rx_thread_entry(void* parameter)
while (1) while (1)
{ {
if(device->eth_rx == RT_NULL) break; if(device->eth_rx == RT_NULL) break;
p = device->eth_rx(&(device->parent)); p = device->eth_rx(&(device->parent));
if (p != RT_NULL) if (p != RT_NULL)
{ {
......
...@@ -531,6 +531,13 @@ ...@@ -531,6 +531,13 @@
#define LWIP_TCP_KEEPALIVE 1 #define LWIP_TCP_KEEPALIVE 1
#endif #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) * LWIP_NETIF_API==1: Support netif api (in netifapi.c)
*/ */
......
...@@ -173,7 +173,7 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled) ...@@ -173,7 +173,7 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled)
extern int lwip_ping_recv(int s, int *ttl); extern int lwip_ping_recv(int s, int *ttl);
extern err_t lwip_ping_send(int s, ip_addr_t *addr, int size); extern err_t lwip_ping_send(int s, ip_addr_t *addr, int size);
int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len, int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
uint32_t timeout, struct netdev_ping_resp *ping_resp) uint32_t timeout, struct netdev_ping_resp *ping_resp)
{ {
int s, ttl, recv_len, result = 0; int s, ttl, recv_len, result = 0;
...@@ -188,7 +188,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len, ...@@ -188,7 +188,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
struct addrinfo hint, *res = RT_NULL; struct addrinfo hint, *res = RT_NULL;
struct sockaddr_in *h = RT_NULL; struct sockaddr_in *h = RT_NULL;
struct in_addr ina; struct in_addr ina;
RT_ASSERT(netif); RT_ASSERT(netif);
RT_ASSERT(host); RT_ASSERT(host);
RT_ASSERT(ping_resp); RT_ASSERT(ping_resp);
...@@ -207,7 +207,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len, ...@@ -207,7 +207,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
return -RT_ERROR; return -RT_ERROR;
} }
rt_memcpy(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t)); rt_memcpy(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t));
/* new a socket */ /* new a socket */
if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0) if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0)
{ {
...@@ -275,7 +275,7 @@ const struct netdev_ops lwip_netdev_ops = ...@@ -275,7 +275,7 @@ const struct netdev_ops lwip_netdev_ops =
lwip_netdev_set_addr_info, lwip_netdev_set_addr_info,
#ifdef RT_LWIP_DNS #ifdef RT_LWIP_DNS
lwip_netdev_set_dns_server, lwip_netdev_set_dns_server,
#else #else
NULL, NULL,
#endif /* RT_LWIP_DNS */ #endif /* RT_LWIP_DNS */
...@@ -323,8 +323,8 @@ static int netdev_add(struct netif *lwip_netif) ...@@ -323,8 +323,8 @@ static int netdev_add(struct netif *lwip_netif)
rt_strncpy(name, lwip_netif->name, LWIP_NETIF_NAME_LEN); rt_strncpy(name, lwip_netif->name, LWIP_NETIF_NAME_LEN);
result = netdev_register(netdev, name, (void *)lwip_netif); result = netdev_register(netdev, name, (void *)lwip_netif);
/* Update netdev info after registered */ /* Update netdev info after registered */
netdev->flags = lwip_netif->flags; netdev->flags = lwip_netif->flags;
netdev->mtu = lwip_netif->mtu; netdev->mtu = lwip_netif->mtu;
netdev->ops = &lwip_netdev_ops; netdev->ops = &lwip_netdev_ops;
...@@ -333,7 +333,7 @@ static int netdev_add(struct netif *lwip_netif) ...@@ -333,7 +333,7 @@ static int netdev_add(struct netif *lwip_netif)
netdev->ip_addr = lwip_netif->ip_addr; netdev->ip_addr = lwip_netif->ip_addr;
netdev->gw = lwip_netif->gw; netdev->gw = lwip_netif->gw;
netdev->netmask = lwip_netif->netmask; netdev->netmask = lwip_netif->netmask;
#ifdef RT_LWIP_DHCP #ifdef RT_LWIP_DHCP
netdev_low_level_set_dhcp_status(netdev, RT_TRUE); netdev_low_level_set_dhcp_status(netdev, RT_TRUE);
#endif #endif
...@@ -412,7 +412,7 @@ static err_t eth_netif_device_init(struct netif *netif) ...@@ -412,7 +412,7 @@ static err_t eth_netif_device_init(struct netif *netif)
/* network interface device register */ /* network interface device register */
netdev_add(netif); netdev_add(netif);
#endif /* RT_USING_NETDEV */ #endif /* RT_USING_NETDEV */
ethif = (struct eth_device*)netif->state; ethif = (struct eth_device*)netif->state;
if (ethif != RT_NULL) if (ethif != RT_NULL)
{ {
...@@ -481,8 +481,13 @@ static err_t eth_netif_device_init(struct netif *netif) ...@@ -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) rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flags)
{ {
struct netif* netif; 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)); netif = (struct netif*) rt_malloc (sizeof(struct netif));
#endif
if (netif == RT_NULL) if (netif == RT_NULL)
{ {
rt_kprintf("malloc netif failed\n"); 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_ ...@@ -519,7 +524,9 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
#if LWIP_NETIF_HOSTNAME #if LWIP_NETIF_HOSTNAME
/* Initialize interface 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 */ #endif /* LWIP_NETIF_HOSTNAME */
/* if tcp thread has been started up, we add this netif to the system */ /* if tcp thread has been started up, we add this netif to the system */
...@@ -531,7 +538,7 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ ...@@ -531,7 +538,7 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
ipaddr.addr = inet_addr(RT_LWIP_IPADDR); ipaddr.addr = inet_addr(RT_LWIP_IPADDR);
gw.addr = inet_addr(RT_LWIP_GWADDR); gw.addr = inet_addr(RT_LWIP_GWADDR);
netmask.addr = inet_addr(RT_LWIP_MSKADDR); netmask.addr = inet_addr(RT_LWIP_MSKADDR);
#else #else
IP4_ADDR(&ipaddr, 0, 0, 0, 0); IP4_ADDR(&ipaddr, 0, 0, 0, 0);
IP4_ADDR(&gw, 0, 0, 0, 0); IP4_ADDR(&gw, 0, 0, 0, 0);
IP4_ADDR(&netmask, 0, 0, 0, 0); IP4_ADDR(&netmask, 0, 0, 0, 0);
...@@ -683,7 +690,7 @@ static void eth_rx_thread_entry(void* parameter) ...@@ -683,7 +690,7 @@ static void eth_rx_thread_entry(void* parameter)
while (1) while (1)
{ {
if(device->eth_rx == RT_NULL) break; if(device->eth_rx == RT_NULL) break;
p = device->eth_rx(&(device->parent)); p = device->eth_rx(&(device->parent));
if (p != RT_NULL) if (p != RT_NULL)
{ {
...@@ -706,9 +713,9 @@ static void eth_rx_thread_entry(void* parameter) ...@@ -706,9 +713,9 @@ static void eth_rx_thread_entry(void* parameter)
} }
#endif #endif
/* this function does not need, /* this function does not need,
* use eth_system_device_init_private() * use eth_system_device_init_private()
* call by lwip_system_init(). * call by lwip_system_init().
*/ */
int eth_system_device_init(void) int eth_system_device_init(void)
{ {
...@@ -855,22 +862,22 @@ void list_if(void) ...@@ -855,22 +862,22 @@ void list_if(void)
ip6_addr_t *addr; ip6_addr_t *addr;
int addr_state; int addr_state;
int i; int i;
addr = (ip6_addr_t *)&netif->ip6_addr[0]; addr = (ip6_addr_t *)&netif->ip6_addr[0];
addr_state = netif->ip6_addr_state[0]; addr_state = netif->ip6_addr_state[0];
rt_kprintf("\nipv6 link-local: %s state:%02X %s\n", ip6addr_ntoa(addr), rt_kprintf("\nipv6 link-local: %s state:%02X %s\n", ip6addr_ntoa(addr),
addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID"); addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID");
for(i=1; i<LWIP_IPV6_NUM_ADDRESSES; i++) for(i=1; i<LWIP_IPV6_NUM_ADDRESSES; i++)
{ {
addr = (ip6_addr_t *)&netif->ip6_addr[i]; addr = (ip6_addr_t *)&netif->ip6_addr[i];
addr_state = netif->ip6_addr_state[i]; addr_state = netif->ip6_addr_state[i];
rt_kprintf("ipv6[%d] address: %s state:%02X %s\n", i, ip6addr_ntoa(addr), rt_kprintf("ipv6[%d] address: %s state:%02X %s\n", i, ip6addr_ntoa(addr),
addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID"); addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID");
} }
} }
rt_kprintf("\r\n"); rt_kprintf("\r\n");
#endif /* LWIP_IPV6 */ #endif /* LWIP_IPV6 */
......
...@@ -538,6 +538,13 @@ ...@@ -538,6 +538,13 @@
#define LWIP_TCP_KEEPALIVE 1 #define LWIP_TCP_KEEPALIVE 1
#endif #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) * LWIP_NETIF_API==1: Support netif api (in netifapi.c)
*/ */
......
...@@ -174,7 +174,7 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled) ...@@ -174,7 +174,7 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled)
extern int lwip_ping_recv(int s, int *ttl); extern int lwip_ping_recv(int s, int *ttl);
extern err_t lwip_ping_send(int s, ip_addr_t *addr, int size); extern err_t lwip_ping_send(int s, ip_addr_t *addr, int size);
int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len, int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
uint32_t timeout, struct netdev_ping_resp *ping_resp) uint32_t timeout, struct netdev_ping_resp *ping_resp)
{ {
int s, ttl, recv_len, result = 0; int s, ttl, recv_len, result = 0;
...@@ -189,7 +189,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len, ...@@ -189,7 +189,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
struct addrinfo hint, *res = RT_NULL; struct addrinfo hint, *res = RT_NULL;
struct sockaddr_in *h = RT_NULL; struct sockaddr_in *h = RT_NULL;
struct in_addr ina; struct in_addr ina;
RT_ASSERT(netif); RT_ASSERT(netif);
RT_ASSERT(host); RT_ASSERT(host);
RT_ASSERT(ping_resp); RT_ASSERT(ping_resp);
...@@ -208,7 +208,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len, ...@@ -208,7 +208,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
return -RT_ERROR; return -RT_ERROR;
} }
rt_memcpy(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t)); rt_memcpy(&(ping_resp->ip_addr), &target_addr, sizeof(ip_addr_t));
/* new a socket */ /* new a socket */
if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0) if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0)
{ {
...@@ -276,7 +276,7 @@ const struct netdev_ops lwip_netdev_ops = ...@@ -276,7 +276,7 @@ const struct netdev_ops lwip_netdev_ops =
lwip_netdev_set_addr_info, lwip_netdev_set_addr_info,
#ifdef RT_LWIP_DNS #ifdef RT_LWIP_DNS
lwip_netdev_set_dns_server, lwip_netdev_set_dns_server,
#else #else
NULL, NULL,
#endif /* RT_LWIP_DNS */ #endif /* RT_LWIP_DNS */
...@@ -315,7 +315,7 @@ static int netdev_add(struct netif *lwip_netif) ...@@ -315,7 +315,7 @@ static int netdev_add(struct netif *lwip_netif)
{ {
return -ERR_IF; return -ERR_IF;
} }
#ifdef SAL_USING_LWIP #ifdef SAL_USING_LWIP
extern int sal_lwip_netdev_set_pf_info(struct netdev *netdev); extern int sal_lwip_netdev_set_pf_info(struct netdev *netdev);
/* set the lwIP network interface device protocol family information */ /* set the lwIP network interface device protocol family information */
...@@ -324,7 +324,7 @@ static int netdev_add(struct netif *lwip_netif) ...@@ -324,7 +324,7 @@ static int netdev_add(struct netif *lwip_netif)
rt_strncpy(name, lwip_netif->name, LWIP_NETIF_NAME_LEN); rt_strncpy(name, lwip_netif->name, LWIP_NETIF_NAME_LEN);
result = netdev_register(netdev, name, (void *)lwip_netif); result = netdev_register(netdev, name, (void *)lwip_netif);
/* Update netdev info after registered */ /* Update netdev info after registered */
netdev->flags = lwip_netif->flags; netdev->flags = lwip_netif->flags;
netdev->mtu = lwip_netif->mtu; netdev->mtu = lwip_netif->mtu;
...@@ -367,7 +367,7 @@ static int netdev_flags_sync(struct netif *lwip_netif) ...@@ -367,7 +367,7 @@ static int netdev_flags_sync(struct netif *lwip_netif)
{ {
return -ERR_IF; return -ERR_IF;
} }
netdev->mtu = lwip_netif->mtu; netdev->mtu = lwip_netif->mtu;
netdev->flags |= lwip_netif->flags; netdev->flags |= lwip_netif->flags;
...@@ -430,7 +430,7 @@ static err_t eth_netif_device_init(struct netif *netif) ...@@ -430,7 +430,7 @@ static err_t eth_netif_device_init(struct netif *netif)
/* copy device flags to netif flags */ /* copy device flags to netif flags */
netif->flags = (ethif->flags & 0xff); netif->flags = (ethif->flags & 0xff);
netif->mtu = ETHERNET_MTU; netif->mtu = ETHERNET_MTU;
/* set output */ /* set output */
netif->output = etharp_output; netif->output = etharp_output;
...@@ -518,13 +518,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ ...@@ -518,13 +518,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
/* set linkoutput */ /* set linkoutput */
netif->linkoutput = ethernetif_linkoutput; netif->linkoutput = ethernetif_linkoutput;
/* get hardware MAC address */ /* get hardware MAC address */
rt_device_control(&(dev->parent), NIOCTL_GADDR, netif->hwaddr); rt_device_control(&(dev->parent), NIOCTL_GADDR, netif->hwaddr);
#if LWIP_NETIF_HOSTNAME #if LWIP_NETIF_HOSTNAME
/* Initialize interface 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 */ #endif /* LWIP_NETIF_HOSTNAME */
/* if tcp thread has been started up, we add this netif to the system */ /* if tcp thread has been started up, we add this netif to the system */
...@@ -536,7 +538,7 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_ ...@@ -536,7 +538,7 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
ipaddr.addr = inet_addr(RT_LWIP_IPADDR); ipaddr.addr = inet_addr(RT_LWIP_IPADDR);
gw.addr = inet_addr(RT_LWIP_GWADDR); gw.addr = inet_addr(RT_LWIP_GWADDR);
netmask.addr = inet_addr(RT_LWIP_MSKADDR); netmask.addr = inet_addr(RT_LWIP_MSKADDR);
#else #else
IP4_ADDR(&ipaddr, 0, 0, 0, 0); IP4_ADDR(&ipaddr, 0, 0, 0, 0);
IP4_ADDR(&gw, 0, 0, 0, 0); IP4_ADDR(&gw, 0, 0, 0, 0);
IP4_ADDR(&netmask, 0, 0, 0, 0); IP4_ADDR(&netmask, 0, 0, 0, 0);
...@@ -688,7 +690,7 @@ static void eth_rx_thread_entry(void* parameter) ...@@ -688,7 +690,7 @@ static void eth_rx_thread_entry(void* parameter)
while (1) while (1)
{ {
if(device->eth_rx == RT_NULL) break; if(device->eth_rx == RT_NULL) break;
p = device->eth_rx(&(device->parent)); p = device->eth_rx(&(device->parent));
if (p != RT_NULL) if (p != RT_NULL)
{ {
...@@ -711,9 +713,9 @@ static void eth_rx_thread_entry(void* parameter) ...@@ -711,9 +713,9 @@ static void eth_rx_thread_entry(void* parameter)
} }
#endif #endif
/* this function does not need, /* this function does not need,
* use eth_system_device_init_private() * use eth_system_device_init_private()
* call by lwip_system_init(). * call by lwip_system_init().
*/ */
int eth_system_device_init(void) int eth_system_device_init(void)
{ {
...@@ -860,22 +862,22 @@ void list_if(void) ...@@ -860,22 +862,22 @@ void list_if(void)
ip6_addr_t *addr; ip6_addr_t *addr;
int addr_state; int addr_state;
int i; int i;
addr = (ip6_addr_t *)&netif->ip6_addr[0]; addr = (ip6_addr_t *)&netif->ip6_addr[0];
addr_state = netif->ip6_addr_state[0]; addr_state = netif->ip6_addr_state[0];
rt_kprintf("\nipv6 link-local: %s state:%02X %s\n", ip6addr_ntoa(addr), rt_kprintf("\nipv6 link-local: %s state:%02X %s\n", ip6addr_ntoa(addr),
addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID"); addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID");
for(i=1; i<LWIP_IPV6_NUM_ADDRESSES; i++) for(i=1; i<LWIP_IPV6_NUM_ADDRESSES; i++)
{ {
addr = (ip6_addr_t *)&netif->ip6_addr[i]; addr = (ip6_addr_t *)&netif->ip6_addr[i];
addr_state = netif->ip6_addr_state[i]; addr_state = netif->ip6_addr_state[i];
rt_kprintf("ipv6[%d] address: %s state:%02X %s\n", i, ip6addr_ntoa(addr), rt_kprintf("ipv6[%d] address: %s state:%02X %s\n", i, ip6addr_ntoa(addr),
addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID"); addr_state, ip6_addr_isvalid(addr_state)?"VALID":"INVALID");
} }
} }
rt_kprintf("\r\n"); rt_kprintf("\r\n");
#endif /* LWIP_IPV6 */ #endif /* LWIP_IPV6 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册