| 8473 | */ |
| 8474 | |
| 8475 | static struct mbuf * |
| 8476 | key_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 |
no test coverage detected