/* This function will get the first network interface device with the flags in network interface device list. */
struct netdev* netdev_get_first_by_flags(uint16_t flags)
/* This function will get the first network interface device with the flags in network interface device list. */
struct netdev* netdev_get_first_by_flags(uint16_t flags)
{
    rt_base_t level;
    rt_slist_t *node = RT_NULL;
    struct netdev *netdev = RT_NULL;
    if (netdev_list == RT_NULL)
    {
        return RT_NULL;
    }
    level = rt_spin_lock_irqsave(&_spinlock);
    for (node = &(netdev_list->list); node; node = rt_slist_next(node))
    {
        netdev = rt_slist_entry(node, struct netdev, list);
        if (netdev && (netdev->flags & flags) != 0)
        {
            rt_spin_unlock_irqrestore(&_spinlock, level);
            return netdev;
        }
    }
    rt_spin_unlock_irqrestore(&_spinlock, level);
    return RT_NULL;
}