aboutsummaryrefslogtreecommitdiff
path: root/sys/opencrypto/criov.c
diff options
context:
space:
mode:
authorPawel Jakub Dawidek <pjd@FreeBSD.org>2006-06-04 22:15:13 +0000
committerPawel Jakub Dawidek <pjd@FreeBSD.org>2006-06-04 22:15:13 +0000
commit11d2e1e8fff75655552f3144613810f37dd85c2a (patch)
treeeb23ce333a8decabbd11461c164ab6b666abb472 /sys/opencrypto/criov.c
parent694e0113062f91c8ee5c49b9423c89ccca219acb (diff)
downloadsrc-11d2e1e8fff75655552f3144613810f37dd85c2a.tar.gz
src-11d2e1e8fff75655552f3144613810f37dd85c2a.zip
- Replace COPYDATA() and COPYBACK() macros with crypto_copydata() and
crypto_copyback() functions. - Add crypto_apply() function. This will allow for more code simplification.
Notes
Notes: svn path=/head/; revision=159241
Diffstat (limited to 'sys/opencrypto/criov.c')
-rw-r--r--sys/opencrypto/criov.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/sys/opencrypto/criov.c b/sys/opencrypto/criov.c
index fff52fb6cc56..96f0dfc59b66 100644
--- a/sys/opencrypto/criov.c
+++ b/sys/opencrypto/criov.c
@@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/errno.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
+#include <sys/mbuf.h>
#include <sys/uio.h>
#include <opencrypto/cryptodev.h>
@@ -156,3 +157,42 @@ cuio_apply(struct uio *uio, int off, int len, int (*f)(void *, void *, u_int),
}
return (0);
}
+
+void
+crypto_copyback(int flags, caddr_t buf, int off, int size, caddr_t in)
+{
+
+ if ((flags & CRYPTO_F_IMBUF) != 0)
+ m_copyback((struct mbuf *)buf, off, size, in);
+ else if ((flags & CRYPTO_F_IOV) != 0)
+ cuio_copyback((struct uio *)buf, off, size, in);
+ else
+ bcopy(in, buf + off, size);
+}
+
+void
+crypto_copydata(int flags, caddr_t buf, int off, int size, caddr_t out)
+{
+
+ if ((flags & CRYPTO_F_IMBUF) != 0)
+ m_copydata((struct mbuf *)buf, off, size, out);
+ else if ((flags & CRYPTO_F_IOV) != 0)
+ cuio_copydata((struct uio *)buf, off, size, out);
+ else
+ bcopy(buf + off, out, size);
+}
+
+int
+crypto_apply(int flags, caddr_t buf, int off, int len,
+ int (*f)(void *, void *, u_int), void *arg)
+{
+ int error;
+
+ if ((flags & CRYPTO_F_IMBUF) != 0)
+ error = m_apply((struct mbuf *)buf, off, len, f, arg);
+ else if ((flags & CRYPTO_F_IOV) != 0)
+ error = cuio_apply((struct uio *)buf, off, len, f, arg);
+ else
+ error = (*f)(arg, buf + off, len);
+ return (error);
+}