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

Function key_setkey

freebsd/netipsec/key.c:8475–8499  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8473 */
8474
8475static struct mbuf *
8476key_setkey(struct seckey *src, uint16_t exttype)
8477{
8478 struct mbuf *m;
8479 struct sadb_key *p;
8480 int len;
8481
8482 if (src == NULL)
8483 return NULL;
8484
8485 len = PFKEY_ALIGN8(sizeof(struct sadb_key) + _KEYLEN(src));
8486 m = m_get2(len, M_NOWAIT, MT_DATA, 0);
8487 if (m == NULL)
8488 return NULL;
8489 m_align(m, len);
8490 m->m_len = len;
8491 p = mtod(m, struct sadb_key *);
8492 bzero(p, len);
8493 p->sadb_key_len = PFKEY_UNIT64(len);
8494 p->sadb_key_exttype = exttype;
8495 p->sadb_key_bits = src->bits;
8496 bcopy(src->key_data, _KEYBUF(p), _KEYLEN(src));
8497
8498 return m;
8499}
8500
8501/*
8502 * Take one of the kernel's lifetime data structures and convert it

Callers 1

key_setdumpsaFunction · 0.85

Calls 3

m_get2Function · 0.85
bzeroFunction · 0.85
m_alignFunction · 0.50

Tested by

no test coverage detected