mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
net/netdev_findbyaddr.c: Skip network devices that are in the down state. They have no meaning address
This commit is contained in:
@@ -7018,4 +7018,7 @@
|
||||
drivers/usbdev/usbmsc_scsi.c: If DCD can support queuing of stall
|
||||
requests, then the USB MSC stall work around delays are not necessary
|
||||
(2014-3-20).
|
||||
* net/netdev_findbyaddr.c: Skip network devices that are in the
|
||||
"down" state. It does not make sense to consider an address match
|
||||
with a "down" device. From Brennan Ashton (2014-3-20).
|
||||
|
||||
|
||||
@@ -264,7 +264,7 @@ static int usbmsc_bind(FAR struct usbdevclass_driver_s *driver,
|
||||
priv->usbdev = dev;
|
||||
|
||||
/* Save the reference to our private data structure in EP0 so that it
|
||||
* can be recovered in ep0 completion events (Unless we are part of
|
||||
* can be recovered in ep0 completion events (Unless we are part of
|
||||
* a composite device and, in that case, the composite device owns
|
||||
* EP0).
|
||||
*/
|
||||
|
||||
+26
-6
@@ -1,7 +1,7 @@
|
||||
/****************************************************************************
|
||||
* net/netdev_findbyaddr.c
|
||||
*
|
||||
* Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@@ -55,7 +55,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Priviate Types
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
@@ -79,7 +79,8 @@
|
||||
*
|
||||
* Description:
|
||||
* Find a previously registered network device by matching a local address
|
||||
* with the subnet served by the device
|
||||
* with the subnet served by the device. Only "up" devices are considered
|
||||
* (since a "down" device has no meaningful address).
|
||||
*
|
||||
* Parameters:
|
||||
* addr - Pointer to the remote address of a connection
|
||||
@@ -95,17 +96,36 @@
|
||||
static FAR struct uip_driver_s *netdev_finddevice(const uip_ipaddr_t addr)
|
||||
{
|
||||
struct uip_driver_s *dev;
|
||||
uint8_t iff;
|
||||
|
||||
/* Examine each registered network device */
|
||||
|
||||
netdev_semtake();
|
||||
for (dev = g_netdevices; dev; dev = dev->flink)
|
||||
{
|
||||
if (uip_ipaddr_maskcmp(dev->d_ipaddr, addr, dev->d_netmask))
|
||||
/* Get the interface flags */
|
||||
|
||||
if (uip_getifstatus(dev->d_ifname, &iff) == OK)
|
||||
{
|
||||
netdev_semgive();
|
||||
return dev;
|
||||
/* Is the interface in the "up" state? */
|
||||
|
||||
if ((iff & IFF_UP) != 0)
|
||||
{
|
||||
/* Yes.. check for an address match (under the netmask) */
|
||||
|
||||
if (uip_ipaddr_maskcmp(dev->d_ipaddr, addr, dev->d_netmask))
|
||||
{
|
||||
/* Its a match */
|
||||
|
||||
netdev_semgive();
|
||||
return dev;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* No device with the matching address found */
|
||||
|
||||
netdev_semgive();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user