MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / netdev_get_by_name

Function netdev_get_by_name

components/net/netdev/src/netdev.c:308–333  ·  view source on GitHub ↗

* This function will get network interface device * in network interface device list by netdev name. * * @param name the network interface device name * * @return != NULL: network interface device object * NULL: get failed */

Source from the content-addressed store, hash-verified

306 * NULL: get failed
307 */
308struct netdev *netdev_get_by_name(const char *name)
309{
310 rt_slist_t *node = RT_NULL;
311 struct netdev *netdev = RT_NULL;
312
313 if (netdev_list == RT_NULL)
314 {
315 return RT_NULL;
316 }
317
318 rt_spin_lock(&_spinlock);
319
320 for (node = &(netdev_list->list); node; node = rt_slist_next(node))
321 {
322 netdev = rt_slist_entry(node, struct netdev, list);
323 if (netdev && (rt_strncmp(netdev->name, name, rt_strlen(name) < RT_NAME_MAX ? rt_strlen(name) : RT_NAME_MAX) == 0))
324 {
325 rt_spin_unlock(&_spinlock);
326 return netdev;
327 }
328 }
329
330 rt_spin_unlock(&_spinlock);
331
332 return RT_NULL;
333}
334
335/**
336 * This function will get network interface device

Callers 15

rndis_lwip_initFunction · 0.85
netif_do_set_ipaddrFunction · 0.85
netif_do_set_netmaskFunction · 0.85
netif_do_set_gwFunction · 0.85
netif_set_upFunction · 0.85
netif_set_downFunction · 0.85
netif_set_link_upFunction · 0.85
netif_set_link_downFunction · 0.85
netif_add_ip6_addressFunction · 0.85
dns_setserverFunction · 0.85

Calls 5

rt_slist_nextFunction · 0.85
rt_strncmpFunction · 0.85
rt_strlenFunction · 0.85
rt_spin_lockFunction · 0.50
rt_spin_unlockFunction · 0.50

Tested by 3