* not really an official behavior. discussed in pf_key@inner.net in Sep2000. * XXX reorder combinations by preference */
| 6434 | * XXX reorder combinations by preference |
| 6435 | */ |
| 6436 | static struct mbuf * |
| 6437 | key_getcomb_ipcomp() |
| 6438 | { |
| 6439 | const struct comp_algo *algo; |
| 6440 | struct sadb_comb *comb; |
| 6441 | struct mbuf *m; |
| 6442 | int i; |
| 6443 | const int l = PFKEY_ALIGN8(sizeof(struct sadb_comb)); |
| 6444 | |
| 6445 | m = NULL; |
| 6446 | for (i = 1; i <= SADB_X_CALG_MAX; i++) { |
| 6447 | algo = comp_algorithm_lookup(i); |
| 6448 | if (!algo) |
| 6449 | continue; |
| 6450 | |
| 6451 | if (!m) { |
| 6452 | IPSEC_ASSERT(l <= MLEN, |
| 6453 | ("l=%u > MLEN=%lu", l, (u_long) MLEN)); |
| 6454 | MGET(m, M_NOWAIT, MT_DATA); |
| 6455 | if (m) { |
| 6456 | M_ALIGN(m, l); |
| 6457 | m->m_len = l; |
| 6458 | m->m_next = NULL; |
| 6459 | } |
| 6460 | } else |
| 6461 | M_PREPEND(m, l, M_NOWAIT); |
| 6462 | if (!m) |
| 6463 | return NULL; |
| 6464 | |
| 6465 | comb = mtod(m, struct sadb_comb *); |
| 6466 | bzero(comb, sizeof(*comb)); |
| 6467 | key_getcomb_setlifetime(comb); |
| 6468 | comb->sadb_comb_encrypt = i; |
| 6469 | /* what should we set into sadb_comb_*_{min,max}bits? */ |
| 6470 | } |
| 6471 | |
| 6472 | return m; |
| 6473 | } |
| 6474 | |
| 6475 | /* |
| 6476 | * XXX no way to pass mode (transport/tunnel) to userland |
no test coverage detected