Page MenuHomeFreeBSD

D39138.diff
No OneTemporary

D39138.diff

diff --git a/sys/net/if.c b/sys/net/if.c
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -4600,6 +4600,42 @@
return (error);
}
+
+/*
+ * Uses just 1 pointer of the 4 available in the public struct.
+ */
+if_t
+if_iter_start(struct if_iter *iter)
+{
+ if_t ifp;
+
+ NET_EPOCH_ASSERT();
+
+ bzero(iter, sizeof(*iter));
+ ifp = CK_STAILQ_FIRST(&V_ifnet);
+ if (ifp != NULL)
+ iter->context[0] = CK_STAILQ_NEXT(ifp, if_link);
+ else
+ iter->context[0] = NULL;
+ return (ifp);
+}
+
+if_t
+if_iter_next(struct if_iter *iter)
+{
+ if_t cur_ifp = iter->context[0];
+
+ if (cur_ifp != NULL)
+ iter->context[0] = CK_STAILQ_NEXT(cur_ifp, if_link);
+ return (cur_ifp);
+}
+
+void
+if_iter_finish(struct if_iter *iter)
+{
+ /* Nothing to do here for now. */
+}
+
u_int
if_foreach_lladdr(if_t ifp, iflladdr_cb_t cb, void *cb_arg)
{
diff --git a/sys/net/if_var.h b/sys/net/if_var.h
--- a/sys/net/if_var.h
+++ b/sys/net/if_var.h
@@ -684,6 +684,15 @@
int if_foreach(if_foreach_cb_t, void *);
int if_foreach_sleep(if_foreach_match_t, void *, if_foreach_cb_t, void *);
+/* Opaque iterator structure for iterating over interfaces. */
+struct if_iter {
+ void *context[4];
+};
+
+if_t if_iter_start(struct if_iter *);
+if_t if_iter_next(struct if_iter *);
+void if_iter_finish(struct if_iter *);
+
/* Functions */
void if_setinitfn(if_t ifp, if_init_fn_t);
void if_setinputfn(if_t ifp, if_input_fn_t);

File Metadata

Mime Type
text/plain
Expires
Thu, Jan 9, 3:58 PM (9 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15733100
Default Alt Text
D39138.diff (1 KB)

Event Timeline