浏览代码

components: net: lwip: port: add netdev callback on link status change setting

- set netdev callback on link status change in netdev_add()

Signed-off-by: Jiading Xu <Jiading.Xu@hpmicro.com>
Jiading Xu 1 年之前
父节点
当前提交
79457efc49
共有 2 个文件被更改,包括 10 次插入1 次删除
  1. 5 0
      components/net/lwip/port/ethernetif.c
  2. 5 1
      components/net/netdev/Kconfig

+ 5 - 0
components/net/lwip/port/ethernetif.c

@@ -421,6 +421,11 @@ static int netdev_add(struct netif *lwip_netif)
     netdev->gw = lwip_netif->gw;
     netdev->netmask = lwip_netif->netmask;
 
+#ifdef NETDEV_USING_LINK_STATUS_CALLBACK
+    extern void netdev_status_change(struct netdev *netdev, enum netdev_cb_type type);
+    netdev_set_status_callback(netdev, netdev_status_change);
+#endif
+
     return result;
 }
 

+ 5 - 1
components/net/netdev/Kconfig

@@ -19,7 +19,11 @@ if RT_USING_NETDEV
     config NETDEV_USING_AUTO_DEFAULT
         bool "Enable default netdev automatic change features"
         default y
-
+	
+    config NETDEV_USING_LINK_STATUS_CALLBACK
+    	bool "Enable netdev callback on link status change"
+    	default n
+	
     config NETDEV_USING_IPV6
         bool "Enable IPV6 protocol support"
         default n