* m will not be freed on return. * it is caller's responsibility to free the result. * * Called from SADB_ADD and SADB_UPDATE. Reply will contain headers * from the request in defined order. */
| 5905 | * from the request in defined order. |
| 5906 | */ |
| 5907 | static struct mbuf * |
| 5908 | key_getmsgbuf_x1(struct mbuf *m, const struct sadb_msghdr *mhp) |
| 5909 | { |
| 5910 | struct mbuf *n; |
| 5911 | |
| 5912 | IPSEC_ASSERT(m != NULL, ("null mbuf")); |
| 5913 | IPSEC_ASSERT(mhp != NULL, ("null msghdr")); |
| 5914 | IPSEC_ASSERT(mhp->msg != NULL, ("null msg")); |
| 5915 | |
| 5916 | /* create new sadb_msg to reply. */ |
| 5917 | n = key_gather_mbuf(m, mhp, 1, 16, SADB_EXT_RESERVED, |
| 5918 | SADB_EXT_SA, SADB_X_EXT_SA2, |
| 5919 | SADB_EXT_ADDRESS_SRC, SADB_EXT_ADDRESS_DST, |
| 5920 | SADB_EXT_LIFETIME_HARD, SADB_EXT_LIFETIME_SOFT, |
| 5921 | SADB_EXT_IDENTITY_SRC, SADB_EXT_IDENTITY_DST, |
| 5922 | SADB_X_EXT_NAT_T_TYPE, SADB_X_EXT_NAT_T_SPORT, |
| 5923 | SADB_X_EXT_NAT_T_DPORT, SADB_X_EXT_NAT_T_OAI, |
| 5924 | SADB_X_EXT_NAT_T_OAR, SADB_X_EXT_NEW_ADDRESS_SRC, |
| 5925 | SADB_X_EXT_NEW_ADDRESS_DST); |
| 5926 | if (!n) |
| 5927 | return NULL; |
| 5928 | |
| 5929 | if (n->m_len < sizeof(struct sadb_msg)) { |
| 5930 | n = m_pullup(n, sizeof(struct sadb_msg)); |
| 5931 | if (n == NULL) |
| 5932 | return NULL; |
| 5933 | } |
| 5934 | mtod(n, struct sadb_msg *)->sadb_msg_errno = 0; |
| 5935 | mtod(n, struct sadb_msg *)->sadb_msg_len = |
| 5936 | PFKEY_UNIT64(n->m_pkthdr.len); |
| 5937 | |
| 5938 | return n; |
| 5939 | } |
| 5940 | |
| 5941 | /* |
| 5942 | * SADB_DELETE processing |
no test coverage detected