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

Function netdev_get_by_ipaddr

components/net/netdev/src/netdev.c:272–297  ·  view source on GitHub ↗

* This function will get the first network interface device * in network interface device list by IP address. * * @param ip_addr the network interface device IP address * * @return != NULL: network interface device object * NULL: get failed */

Source from the content-addressed store, hash-verified

270 * NULL: get failed
271 */
272struct netdev *netdev_get_by_ipaddr(ip_addr_t *ip_addr)
273{
274 rt_slist_t *node = RT_NULL;
275 struct netdev *netdev = RT_NULL;
276
277 if (netdev_list == RT_NULL)
278 {
279 return RT_NULL;
280 }
281
282 rt_spin_lock(&_spinlock);
283
284 for (node = &(netdev_list->list); node; node = rt_slist_next(node))
285 {
286 netdev = rt_slist_entry(node, struct netdev, list);
287 if (netdev && ip_addr_cmp(&(netdev->ip_addr), ip_addr))
288 {
289 rt_spin_unlock(&_spinlock);
290 return netdev;
291 }
292 }
293
294 rt_spin_unlock(&_spinlock);
295
296 return RT_NULL;
297}
298
299/**
300 * This function will get network interface device

Callers 3

sal_bindFunction · 0.85

Calls 4

rt_slist_nextFunction · 0.85
ip_addr_cmpFunction · 0.85
rt_spin_lockFunction · 0.50
rt_spin_unlockFunction · 0.50

Tested by 2