| 861 | max(sizeof(struct newesp) + EALG_MAX_BLOCK_LEN, /* ESP + IV */ \ |
| 862 | sizeof(struct newah) + HASH_MAX_LEN /* AH + ICV */)) |
| 863 | static struct mbuf * |
| 864 | ipsec_prepend(struct mbuf *m, int len, int how) |
| 865 | { |
| 866 | struct mbuf *n; |
| 867 | |
| 868 | M_ASSERTPKTHDR(m); |
| 869 | IPSEC_ASSERT(len < MHLEN, ("wrong length")); |
| 870 | if (M_LEADINGSPACE(m) >= len) { |
| 871 | /* No need to allocate new mbuf. */ |
| 872 | m->m_data -= len; |
| 873 | m->m_len += len; |
| 874 | m->m_pkthdr.len += len; |
| 875 | return (m); |
| 876 | } |
| 877 | n = m_gethdr(how, m->m_type); |
| 878 | if (n == NULL) { |
| 879 | m_freem(m); |
| 880 | return (NULL); |
| 881 | } |
| 882 | m_move_pkthdr(n, m); |
| 883 | n->m_next = m; |
| 884 | if (len + IPSEC_TRAILINGSPACE < M_SIZE(n)) |
| 885 | m_align(n, len + IPSEC_TRAILINGSPACE); |
| 886 | n->m_len = len; |
| 887 | n->m_pkthdr.len += len; |
| 888 | return (n); |
| 889 | } |
| 890 | |
| 891 | static int |
| 892 | ipsec_encap(struct mbuf **mp, struct secasindex *saidx) |
no test coverage detected