@@ -174,7 +174,7 @@ static int lwip_netdev_set_dhcp(struct netdev *netif, rt_bool_t is_enabled)
174174extern int lwip_ping_recv (int s , int * ttl );
175175extern err_t lwip_ping_send (int s , ip_addr_t * addr , int size );
176176
177- int lwip_netdev_ping (struct netdev * netif , const char * host , size_t data_len ,
177+ int lwip_netdev_ping (struct netdev * netif , const char * host , size_t data_len ,
178178 uint32_t timeout , struct netdev_ping_resp * ping_resp )
179179{
180180 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,
189189 struct addrinfo hint , * res = RT_NULL ;
190190 struct sockaddr_in * h = RT_NULL ;
191191 struct in_addr ina ;
192-
192+
193193 RT_ASSERT (netif );
194194 RT_ASSERT (host );
195195 RT_ASSERT (ping_resp );
@@ -208,7 +208,7 @@ int lwip_netdev_ping(struct netdev *netif, const char *host, size_t data_len,
208208 return - RT_ERROR ;
209209 }
210210 rt_memcpy (& (ping_resp -> ip_addr ), & target_addr , sizeof (ip_addr_t ));
211-
211+
212212 /* new a socket */
213213 if ((s = lwip_socket (AF_INET , SOCK_RAW , IP_PROTO_ICMP )) < 0 )
214214 {
@@ -276,7 +276,7 @@ const struct netdev_ops lwip_netdev_ops =
276276 lwip_netdev_set_addr_info ,
277277#ifdef RT_LWIP_DNS
278278 lwip_netdev_set_dns_server ,
279- #else
279+ #else
280280 NULL ,
281281#endif /* RT_LWIP_DNS */
282282
@@ -315,7 +315,7 @@ static int netdev_add(struct netif *lwip_netif)
315315 {
316316 return - ERR_IF ;
317317 }
318-
318+
319319#ifdef SAL_USING_LWIP
320320 extern int sal_lwip_netdev_set_pf_info (struct netdev * netdev );
321321 /* set the lwIP network interface device protocol family information */
@@ -324,7 +324,7 @@ static int netdev_add(struct netif *lwip_netif)
324324
325325 rt_strncpy (name , lwip_netif -> name , LWIP_NETIF_NAME_LEN );
326326 result = netdev_register (netdev , name , (void * )lwip_netif );
327-
327+
328328 /* Update netdev info after registered */
329329 netdev -> flags = lwip_netif -> flags ;
330330 netdev -> mtu = lwip_netif -> mtu ;
@@ -367,7 +367,7 @@ static int netdev_flags_sync(struct netif *lwip_netif)
367367 {
368368 return - ERR_IF ;
369369 }
370-
370+
371371 netdev -> mtu = lwip_netif -> mtu ;
372372 netdev -> flags |= lwip_netif -> flags ;
373373
@@ -430,7 +430,7 @@ static err_t eth_netif_device_init(struct netif *netif)
430430 /* copy device flags to netif flags */
431431 netif -> flags = (ethif -> flags & 0xff );
432432 netif -> mtu = ETHERNET_MTU ;
433-
433+
434434 /* set output */
435435 netif -> output = etharp_output ;
436436
@@ -518,13 +518,15 @@ rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_
518518
519519 /* set linkoutput */
520520 netif -> linkoutput = ethernetif_linkoutput ;
521-
521+
522522 /* get hardware MAC address */
523523 rt_device_control (& (dev -> parent ), NIOCTL_GADDR , netif -> hwaddr );
524524
525525#if LWIP_NETIF_HOSTNAME
526526 /* Initialize interface hostname */
527- netif -> hostname = "rtthread" ;
527+ hostname = (char * )netif + sizeof (struct netif );
528+ rt_sprintf (hostname , "rtthread_%02x%02x" , name [0 ], name [1 ]);
529+ netif -> hostname = hostname ;
528530#endif /* LWIP_NETIF_HOSTNAME */
529531
530532 /* 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_
536538 ipaddr .addr = inet_addr (RT_LWIP_IPADDR );
537539 gw .addr = inet_addr (RT_LWIP_GWADDR );
538540 netmask .addr = inet_addr (RT_LWIP_MSKADDR );
539- #else
541+ #else
540542 IP4_ADDR (& ipaddr , 0 , 0 , 0 , 0 );
541543 IP4_ADDR (& gw , 0 , 0 , 0 , 0 );
542544 IP4_ADDR (& netmask , 0 , 0 , 0 , 0 );
@@ -688,7 +690,7 @@ static void eth_rx_thread_entry(void* parameter)
688690 while (1 )
689691 {
690692 if (device -> eth_rx == RT_NULL ) break ;
691-
693+
692694 p = device -> eth_rx (& (device -> parent ));
693695 if (p != RT_NULL )
694696 {
@@ -711,9 +713,9 @@ static void eth_rx_thread_entry(void* parameter)
711713}
712714#endif
713715
714- /* this function does not need,
715- * use eth_system_device_init_private()
716- * call by lwip_system_init().
716+ /* this function does not need,
717+ * use eth_system_device_init_private()
718+ * call by lwip_system_init().
717719 */
718720int eth_system_device_init (void )
719721{
@@ -860,22 +862,22 @@ void list_if(void)
860862 ip6_addr_t * addr ;
861863 int addr_state ;
862864 int i ;
863-
865+
864866 addr = (ip6_addr_t * )& netif -> ip6_addr [0 ];
865867 addr_state = netif -> ip6_addr_state [0 ];
866-
867- rt_kprintf ("\nipv6 link-local: %s state:%02X %s\n" , ip6addr_ntoa (addr ),
868+
869+ rt_kprintf ("\nipv6 link-local: %s state:%02X %s\n" , ip6addr_ntoa (addr ),
868870 addr_state , ip6_addr_isvalid (addr_state )?"VALID" :"INVALID" );
869-
871+
870872 for (i = 1 ; i < LWIP_IPV6_NUM_ADDRESSES ; i ++ )
871873 {
872874 addr = (ip6_addr_t * )& netif -> ip6_addr [i ];
873875 addr_state = netif -> ip6_addr_state [i ];
874-
875- rt_kprintf ("ipv6[%d] address: %s state:%02X %s\n" , i , ip6addr_ntoa (addr ),
876+
877+ rt_kprintf ("ipv6[%d] address: %s state:%02X %s\n" , i , ip6addr_ntoa (addr ),
876878 addr_state , ip6_addr_isvalid (addr_state )?"VALID" :"INVALID" );
877879 }
878-
880+
879881 }
880882 rt_kprintf ("\r\n" );
881883#endif /* LWIP_IPV6 */
0 commit comments