summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/uipc_mbuf.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/sys/kern/uipc_mbuf.c b/sys/kern/uipc_mbuf.c
index c63c3eabf0b..84f0d8efe9d 100644
--- a/sys/kern/uipc_mbuf.c
+++ b/sys/kern/uipc_mbuf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: uipc_mbuf.c,v 1.19 1999/12/31 23:37:08 provos Exp $ */
+/* $OpenBSD: uipc_mbuf.c,v 1.20 2000/03/02 21:40:49 angelos Exp $ */
/* $NetBSD: uipc_mbuf.c,v 1.15.4.1 1996/06/13 17:11:44 cgd Exp $ */
/*
@@ -721,6 +721,42 @@ bad:
}
/*
+ * Return a pointer to mbuf/offset of location in mbuf chain.
+ */
+struct mbuf *
+m_getptr(struct mbuf *m, int loc, int *off)
+{
+ while (loc >= 0)
+ {
+ /* Normal end of search */
+ if (m->m_len > loc)
+ {
+ *off = loc;
+ return m;
+ }
+ else
+ {
+ loc -= m->m_len;
+
+ if (m->m_next == NULL)
+ {
+ if (loc == 0)
+ {
+ *off = m->m_len; /* Point at the end of valid data */
+ return m;
+ }
+ else
+ return NULL;
+ }
+ else
+ m = m->m_next;
+ }
+ }
+
+ return NULL;
+}
+
+/*
* Inject a new mbuf chain of length siz in mbuf chain m0 at
* position len0. Returns a pointer to the first injected mbuf, or
* NULL on failure (m0 is left undisturbed). Note that if there is