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

Function key_setsadbmsg

freebsd/netipsec/key.c:3741–3777  ·  view source on GitHub ↗

* set data into sadb_msg. */

Source from the content-addressed store, hash-verified

3739 * set data into sadb_msg.
3740 */
3741static struct mbuf *
3742key_setsadbmsg(u_int8_t type, u_int16_t tlen, u_int8_t satype, u_int32_t seq,
3743 pid_t pid, u_int16_t reserved)
3744{
3745 struct mbuf *m;
3746 struct sadb_msg *p;
3747 int len;
3748
3749 len = PFKEY_ALIGN8(sizeof(struct sadb_msg));
3750 if (len > MCLBYTES)
3751 return NULL;
3752 MGETHDR(m, M_NOWAIT, MT_DATA);
3753 if (m && len > MHLEN) {
3754 if (!(MCLGET(m, M_NOWAIT))) {
3755 m_freem(m);
3756 m = NULL;
3757 }
3758 }
3759 if (!m)
3760 return NULL;
3761 m->m_pkthdr.len = m->m_len = len;
3762 m->m_next = NULL;
3763
3764 p = mtod(m, struct sadb_msg *);
3765
3766 bzero(p, len);
3767 p->sadb_msg_version = PF_KEY_V2;
3768 p->sadb_msg_type = type;
3769 p->sadb_msg_errno = 0;
3770 p->sadb_msg_satype = satype;
3771 p->sadb_msg_len = PFKEY_UNIT64(tlen);
3772 p->sadb_msg_reserved = reserved;
3773 p->sadb_msg_seq = seq;
3774 p->sadb_msg_pid = (u_int32_t)pid;
3775
3776 return m;
3777}
3778
3779/*
3780 * copy secasvar data into sadb_address.

Callers 6

key_spdacquireFunction · 0.85
key_setdumpspFunction · 0.85
key_spdexpireFunction · 0.85
key_setdumpsaFunction · 0.85
key_acquireFunction · 0.85
key_expireFunction · 0.85

Calls 2

bzeroFunction · 0.85
m_freemFunction · 0.50

Tested by

no test coverage detected