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

Function key_getspi

freebsd/netipsec/key.c:4812–4991  ·  view source on GitHub ↗

%%% PF_KEY */ * SADB_GETSPI processing is to receive * * from the IKMPd, to assign a unique spi value, to hang on the INBOUND * tree with the status of LARVAL, and send * * to the IKMPd. * * IN: mhp: pointer to the pointer to each header. * OUT: NULL if fail. * other if success, return pointer to the message t

Source from the content-addressed store, hash-verified

4810 * other if success, return pointer to the message to send.
4811 */
4812static int
4813key_getspi(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp)
4814{
4815 struct secasindex saidx;
4816 struct sadb_address *src0, *dst0;
4817 struct secasvar *sav;
4818 uint32_t reqid, spi;
4819 int error;
4820 uint8_t mode, proto;
4821
4822 IPSEC_ASSERT(so != NULL, ("null socket"));
4823 IPSEC_ASSERT(m != NULL, ("null mbuf"));
4824 IPSEC_ASSERT(mhp != NULL, ("null msghdr"));
4825 IPSEC_ASSERT(mhp->msg != NULL, ("null msg"));
4826
4827 if (SADB_CHECKHDR(mhp, SADB_EXT_ADDRESS_SRC) ||
4828 SADB_CHECKHDR(mhp, SADB_EXT_ADDRESS_DST)
4829#ifdef PFKEY_STRICT_CHECKS
4830 || SADB_CHECKHDR(mhp, SADB_EXT_SPIRANGE)
4831#endif
4832 ) {
4833 ipseclog((LOG_DEBUG,
4834 "%s: invalid message: missing required header.\n",
4835 __func__));
4836 error = EINVAL;
4837 goto fail;
4838 }
4839 if (SADB_CHECKLEN(mhp, SADB_EXT_ADDRESS_SRC) ||
4840 SADB_CHECKLEN(mhp, SADB_EXT_ADDRESS_DST)
4841#ifdef PFKEY_STRICT_CHECKS
4842 || SADB_CHECKLEN(mhp, SADB_EXT_SPIRANGE)
4843#endif
4844 ) {
4845 ipseclog((LOG_DEBUG,
4846 "%s: invalid message: wrong header size.\n", __func__));
4847 error = EINVAL;
4848 goto fail;
4849 }
4850 if (SADB_CHECKHDR(mhp, SADB_X_EXT_SA2)) {
4851 mode = IPSEC_MODE_ANY;
4852 reqid = 0;
4853 } else {
4854 if (SADB_CHECKLEN(mhp, SADB_X_EXT_SA2)) {
4855 ipseclog((LOG_DEBUG,
4856 "%s: invalid message: wrong header size.\n",
4857 __func__));
4858 error = EINVAL;
4859 goto fail;
4860 }
4861 mode = ((struct sadb_x_sa2 *)
4862 mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_mode;
4863 reqid = ((struct sadb_x_sa2 *)
4864 mhp->ext[SADB_X_EXT_SA2])->sadb_x_sa2_reqid;
4865 }
4866
4867 src0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_SRC]);
4868 dst0 = (struct sadb_address *)(mhp->ext[SADB_EXT_ADDRESS_DST]);
4869

Callers

nothing calls this directly

Calls 13

key_satype2protoFunction · 0.85
key_checksockaddrsFunction · 0.85
key_do_getnewspiFunction · 0.85
key_newsavFunction · 0.85
key_acqdoneFunction · 0.85
kdebug_secasvFunction · 0.85
m_copydataFunction · 0.85
key_gather_mbufFunction · 0.85
m_pullupFunction · 0.85
key_sendup_mbufFunction · 0.85
key_senderrorFunction · 0.85
printfFunction · 0.50

Tested by

no test coverage detected