* SADB_X_SPDGET processing * receive * * from the user(?), * and send, * * to the ikmpd. * policy(*) including direction of policy. * * m will always be freed. */
| 2368 | * m will always be freed. |
| 2369 | */ |
| 2370 | static int |
| 2371 | key_spdget(struct socket *so, struct mbuf *m, const struct sadb_msghdr *mhp) |
| 2372 | { |
| 2373 | struct secpolicy *sp; |
| 2374 | struct mbuf *n; |
| 2375 | uint32_t id; |
| 2376 | |
| 2377 | IPSEC_ASSERT(so != NULL, ("null socket")); |
| 2378 | IPSEC_ASSERT(m != NULL, ("null mbuf")); |
| 2379 | IPSEC_ASSERT(mhp != NULL, ("null msghdr")); |
| 2380 | IPSEC_ASSERT(mhp->msg != NULL, ("null msg")); |
| 2381 | |
| 2382 | if (SADB_CHECKHDR(mhp, SADB_X_EXT_POLICY) || |
| 2383 | SADB_CHECKLEN(mhp, SADB_X_EXT_POLICY)) { |
| 2384 | ipseclog((LOG_DEBUG, "%s: invalid message is passed.\n", |
| 2385 | __func__)); |
| 2386 | return key_senderror(so, m, EINVAL); |
| 2387 | } |
| 2388 | |
| 2389 | id = ((struct sadb_x_policy *) |
| 2390 | mhp->ext[SADB_X_EXT_POLICY])->sadb_x_policy_id; |
| 2391 | |
| 2392 | /* Is there SP in SPD ? */ |
| 2393 | if ((sp = key_getspbyid(id)) == NULL) { |
| 2394 | ipseclog((LOG_DEBUG, "%s: no SP found for id %u.\n", |
| 2395 | __func__, id)); |
| 2396 | return key_senderror(so, m, ENOENT); |
| 2397 | } |
| 2398 | |
| 2399 | n = key_setdumpsp(sp, SADB_X_SPDGET, mhp->msg->sadb_msg_seq, |
| 2400 | mhp->msg->sadb_msg_pid); |
| 2401 | key_freesp(&sp); |
| 2402 | if (n != NULL) { |
| 2403 | m_freem(m); |
| 2404 | return key_sendup_mbuf(so, n, KEY_SENDUP_ONE); |
| 2405 | } else |
| 2406 | return key_senderror(so, m, ENOBUFS); |
| 2407 | } |
| 2408 | |
| 2409 | /* |
| 2410 | * SADB_X_SPDACQUIRE processing. |
nothing calls this directly
no test coverage detected