netdev/carrier: monitor the driver status

This commit is contained in:
chao.an
2020-04-13 21:36:14 +08:00
committed by Gregory Nutt
parent 10acadb64b
commit 9131ae1f1f
2 changed files with 12 additions and 0 deletions
+3
View File
@@ -51,6 +51,7 @@
#include <nuttx/net/netdev.h> #include <nuttx/net/netdev.h>
#include "netdev/netdev.h" #include "netdev/netdev.h"
#include "netlink/netlink.h"
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
@@ -76,6 +77,7 @@ int netdev_carrier_on(FAR struct net_driver_s *dev)
if (dev) if (dev)
{ {
dev->d_flags |= IFF_RUNNING; dev->d_flags |= IFF_RUNNING;
netlink_device_notify(dev);
return OK; return OK;
} }
@@ -102,6 +104,7 @@ int netdev_carrier_off(FAR struct net_driver_s *dev)
if (dev) if (dev)
{ {
dev->d_flags &= ~IFF_RUNNING; dev->d_flags &= ~IFF_RUNNING;
netlink_device_notify(dev);
return OK; return OK;
} }
+9
View File
@@ -89,6 +89,7 @@
#include "igmp/igmp.h" #include "igmp/igmp.h"
#include "icmpv6/icmpv6.h" #include "icmpv6/icmpv6.h"
#include "route/route.h" #include "route/route.h"
#include "netlink/netlink.h"
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
@@ -1761,6 +1762,10 @@ void netdev_ifup(FAR struct net_driver_s *dev)
/* Mark the interface as up */ /* Mark the interface as up */
dev->d_flags |= IFF_UP; dev->d_flags |= IFF_UP;
/* Update the driver status */
netlink_device_notify(dev);
} }
} }
} }
@@ -1783,6 +1788,10 @@ void netdev_ifdown(FAR struct net_driver_s *dev)
/* Mark the interface as down */ /* Mark the interface as down */
dev->d_flags &= ~IFF_UP; dev->d_flags &= ~IFF_UP;
/* Update the driver status */
netlink_device_notify(dev);
} }
} }