| 659 | } |
| 660 | |
| 661 | int |
| 662 | crypto_apply_buf(struct crypto_buffer *cb, int off, int len, |
| 663 | int (*f)(void *, const void *, u_int), void *arg) |
| 664 | { |
| 665 | int error; |
| 666 | |
| 667 | switch (cb->cb_type) { |
| 668 | case CRYPTO_BUF_MBUF: |
| 669 | error = m_apply(cb->cb_mbuf, off, len, |
| 670 | (int (*)(void *, void *, u_int))f, arg); |
| 671 | break; |
| 672 | case CRYPTO_BUF_UIO: |
| 673 | error = cuio_apply(cb->cb_uio, off, len, f, arg); |
| 674 | break; |
| 675 | #if CRYPTO_MAY_HAVE_VMPAGE |
| 676 | case CRYPTO_BUF_VMPAGE: |
| 677 | error = cvm_page_apply(cb->cb_vm_page, |
| 678 | off + cb->cb_vm_page_offset, len, f, arg); |
| 679 | break; |
| 680 | #endif /* CRYPTO_MAY_HAVE_VMPAGE */ |
| 681 | case CRYPTO_BUF_CONTIG: |
| 682 | MPASS(off + len <= cb->cb_buf_len); |
| 683 | error = (*f)(arg, cb->cb_buf + off, len); |
| 684 | break; |
| 685 | default: |
| 686 | #ifdef INVARIANTS |
| 687 | panic("invalid crypto buf type %d", cb->cb_type); |
| 688 | #endif |
| 689 | error = 0; |
| 690 | break; |
| 691 | } |
| 692 | return (error); |
| 693 | } |
| 694 | |
| 695 | int |
| 696 | crypto_apply(struct cryptop *crp, int off, int len, |
no test coverage detected