MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ah_output

Function ah_output

freebsd/netipsec/xform_ah.c:833–1065  ·  view source on GitHub ↗

* AH output routine, called by ipsec[46]_perform_request(). */

Source from the content-addressed store, hash-verified

831 * AH output routine, called by ipsec[46]_perform_request().
832 */
833static int
834ah_output(struct mbuf *m, struct secpolicy *sp, struct secasvar *sav,
835 u_int idx, int skip, int protoff)
836{
837 IPSEC_DEBUG_DECLARE(char buf[IPSEC_ADDRSTRLEN]);
838 const struct auth_hash *ahx;
839 struct xform_data *xd;
840 struct mbuf *mi;
841 struct cryptop *crp;
842 struct newah *ah;
843 crypto_session_t cryptoid;
844 uint16_t iplen;
845 int error, rplen, authsize, ahsize, maxpacketsize, roff;
846 uint8_t prot;
847 uint32_t seqh;
848
849 IPSEC_ASSERT(sav != NULL, ("null SA"));
850 ahx = sav->tdb_authalgxform;
851 IPSEC_ASSERT(ahx != NULL, ("null authentication xform"));
852
853 AHSTAT_INC(ahs_output);
854
855 /* Figure out header size. */
856 rplen = HDRSIZE(sav);
857 authsize = AUTHSIZE(sav);
858 ahsize = ah_hdrsiz(sav);
859
860 /* Check for maximum packet size violations. */
861 switch (sav->sah->saidx.dst.sa.sa_family) {
862#ifdef INET
863 case AF_INET:
864 maxpacketsize = IP_MAXPACKET;
865 break;
866#endif /* INET */
867#ifdef INET6
868 case AF_INET6:
869 maxpacketsize = IPV6_MAXPACKET;
870 break;
871#endif /* INET6 */
872 default:
873 DPRINTF(("%s: unknown/unsupported protocol family %u, "
874 "SA %s/%08lx\n", __func__,
875 sav->sah->saidx.dst.sa.sa_family,
876 ipsec_address(&sav->sah->saidx.dst, buf, sizeof(buf)),
877 (u_long) ntohl(sav->spi)));
878 AHSTAT_INC(ahs_nopf);
879 error = EPFNOSUPPORT;
880 goto bad;
881 }
882 if (ahsize + m->m_pkthdr.len > maxpacketsize) {
883 DPRINTF(("%s: packet in SA %s/%08lx got too big "
884 "(len %u, max len %u)\n", __func__,
885 ipsec_address(&sav->sah->saidx.dst, buf, sizeof(buf)),
886 (u_long) ntohl(sav->spi),
887 ahsize + m->m_pkthdr.len, maxpacketsize));
888 AHSTAT_INC(ahs_toobig);
889 error = EMSGSIZE;
890 goto bad;

Callers

nothing calls this directly

Calls 15

ah_hdrsizFunction · 0.85
ipsec_addressFunction · 0.85
m_unshareFunction · 0.85
m_makespaceFunction · 0.85
m_copydataFunction · 0.85
m_copybackFunction · 0.85
crypto_getreqFunction · 0.85
mallocFunction · 0.85
crypto_freereqFunction · 0.85
ah_massage_headersFunction · 0.85
crypto_use_mbufFunction · 0.85
crypto_dispatchFunction · 0.85

Tested by

no test coverage detected