MCPcopy Create free account
hub / github.com/apache/nuttx / netdev_nextindex

Function netdev_nextindex

net/netdev/netdev_findbyindex.c:133–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

131
132#ifdef CONFIG_NETDEV_IFINDEX
133int netdev_nextindex(int ifindex)
134{
135 /* The bit index is the interface index minus one. Zero is reserved in
136 * POSIX to mean no interface index.
137 */
138
139 DEBUGASSERT(ifindex > 0 && ifindex <= MAX_IFINDEX);
140 ifindex--;
141
142 if (ifindex >= 0 && ifindex < MAX_IFINDEX)
143 {
144 netdev_list_lock();
145 for (; ifindex < MAX_IFINDEX; ifindex++)
146 {
147 if ((g_devset & (1UL << ifindex)) != 0)
148 {
149 /* NOTE that the index + 1 is returned. Zero is reserved to
150 * mean no-index in the POSIX standards.
151 */
152
153 netdev_list_unlock();
154 return ifindex + 1;
155 }
156 }
157
158 netdev_list_unlock();
159 }
160
161 return -ENODEV;
162}
163#endif

Callers 1

netprocfs_readdirFunction · 0.85

Calls 2

netdev_list_lockFunction · 0.85
netdev_list_unlockFunction · 0.85

Tested by

no test coverage detected