Changeset View
Changeset View
Standalone View
Standalone View
sys/net/if.c
Show First 20 Lines • Show All 4,547 Lines • ▼ Show 20 Lines | union { | ||||
void *match_arg; | void *match_arg; | ||||
int array_len; | int array_len; | ||||
}; | }; | ||||
uint32_t can_sleep:1; | uint32_t can_sleep:1; | ||||
}; | }; | ||||
_Static_assert(sizeof(struct _if_iter_ext) <= sizeof(struct if_iter), | _Static_assert(sizeof(struct _if_iter_ext) <= sizeof(struct if_iter), | ||||
"Public version of if_iter structure is too small"); | "Public version of if_iter structure is too small"); | ||||
int | |||||
if_foreach_sleep(if_foreach_match_t match_cb, void *match_arg, if_foreach_cb_t cb, | |||||
void *cb_arg) | |||||
{ | |||||
struct if_iter_ext_params params = { | |||||
.match_cb = match_cb, | |||||
.match_arg = match_arg, | |||||
.can_sleep = true, | |||||
}; | |||||
struct if_iter it; | |||||
int error = 0; | |||||
for (if_t ifp = if_iter_ext_start(&it, ¶ms); ifp; ifp = if_iter_ext_next(&it)) { | |||||
if (error == 0) | |||||
error = cb(ifp, cb_arg); | |||||
} | |||||
return (error); | |||||
} | |||||
/* | /* | ||||
* Iterates over the list of interfaces, permitting callback function @cb to sleep. | * Iterates over the list of interfaces, permitting callback function @cb to sleep. | ||||
* Stops iteration if @cb returns non-zero error code. | * Stops iteration if @cb returns non-zero error code. | ||||
* Returns the last error code from @cb. | * Returns the last error code from @cb. | ||||
* @match_cb: optional match callback limiting the iteration to only matched interfaces | * @match_cb: optional match callback limiting the iteration to only matched interfaces | ||||
* @match_arg: argument to pass to @match_cb | * @match_arg: argument to pass to @match_cb | ||||
* @cb: iteration callback | * @cb: iteration callback | ||||
* @cb_arg: argument to pass to @cb | * @cb_arg: argument to pass to @cb | ||||
▲ Show 20 Lines • Show All 825 Lines • Show Last 20 Lines |