/* This function will get network interface device in network interface device list by netdev name. */
struct netdev* netdev_get_by_name(const char *name)
/* This function will get network interface device in network interface device list by netdev name. */
struct netdev* netdev_get_by_name(const char *name)
{
    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 && (rt_strncmp(netdev->name, name, rt_strlen(name) < RT_NAME_MAX ? rt_strlen(name) : RT_NAME_MAX) == 0))
        {
            rt_spin_unlock_irqrestore(&_spinlock, level);
            return netdev;
        }
    }
    rt_spin_unlock_irqrestore(&_spinlock, level);
    return RT_NULL;
}