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

Function key_setsadbxpolicy

freebsd/netipsec/key.c:4014–4038  ·  view source on GitHub ↗

* set data into sadb_x_policy */

Source from the content-addressed store, hash-verified

4012 * set data into sadb_x_policy
4013 */
4014static struct mbuf *
4015key_setsadbxpolicy(u_int16_t type, u_int8_t dir, u_int32_t id, u_int32_t priority)
4016{
4017 struct mbuf *m;
4018 struct sadb_x_policy *p;
4019 size_t len;
4020
4021 len = PFKEY_ALIGN8(sizeof(struct sadb_x_policy));
4022 m = m_get2(len, M_NOWAIT, MT_DATA, 0);
4023 if (m == NULL)
4024 return (NULL);
4025 m_align(m, len);
4026 m->m_len = len;
4027 p = mtod(m, struct sadb_x_policy *);
4028
4029 bzero(p, len);
4030 p->sadb_x_policy_len = PFKEY_UNIT64(len);
4031 p->sadb_x_policy_exttype = SADB_X_EXT_POLICY;
4032 p->sadb_x_policy_type = type;
4033 p->sadb_x_policy_dir = dir;
4034 p->sadb_x_policy_id = id;
4035 p->sadb_x_policy_priority = priority;
4036
4037 return m;
4038}
4039
4040/* %%% utilities */
4041/* Take a key message (sadb_key) from the socket and turn it into one

Callers 1

key_acquireFunction · 0.85

Calls 3

m_get2Function · 0.85
bzeroFunction · 0.85
m_alignFunction · 0.50

Tested by

no test coverage detected