| 2622 | } |
| 2623 | |
| 2624 | static struct mbuf * |
| 2625 | key_setdumpsp(struct secpolicy *sp, u_int8_t type, u_int32_t seq, |
| 2626 | u_int32_t pid) |
| 2627 | { |
| 2628 | struct mbuf *result = NULL, *m; |
| 2629 | struct seclifetime lt; |
| 2630 | |
| 2631 | m = key_setsadbmsg(type, 0, SADB_SATYPE_UNSPEC, seq, pid, sp->refcnt); |
| 2632 | if (!m) |
| 2633 | goto fail; |
| 2634 | result = m; |
| 2635 | |
| 2636 | m = key_setsadbaddr(SADB_EXT_ADDRESS_SRC, |
| 2637 | &sp->spidx.src.sa, sp->spidx.prefs, |
| 2638 | sp->spidx.ul_proto); |
| 2639 | if (!m) |
| 2640 | goto fail; |
| 2641 | m_cat(result, m); |
| 2642 | |
| 2643 | m = key_setsadbaddr(SADB_EXT_ADDRESS_DST, |
| 2644 | &sp->spidx.dst.sa, sp->spidx.prefd, |
| 2645 | sp->spidx.ul_proto); |
| 2646 | if (!m) |
| 2647 | goto fail; |
| 2648 | m_cat(result, m); |
| 2649 | |
| 2650 | m = key_sp2mbuf(sp); |
| 2651 | if (!m) |
| 2652 | goto fail; |
| 2653 | m_cat(result, m); |
| 2654 | |
| 2655 | if(sp->lifetime){ |
| 2656 | lt.addtime=sp->created; |
| 2657 | lt.usetime= sp->lastused; |
| 2658 | m = key_setlifetime(<, SADB_EXT_LIFETIME_CURRENT); |
| 2659 | if (!m) |
| 2660 | goto fail; |
| 2661 | m_cat(result, m); |
| 2662 | |
| 2663 | lt.addtime=sp->lifetime; |
| 2664 | lt.usetime= sp->validtime; |
| 2665 | m = key_setlifetime(<, SADB_EXT_LIFETIME_HARD); |
| 2666 | if (!m) |
| 2667 | goto fail; |
| 2668 | m_cat(result, m); |
| 2669 | } |
| 2670 | |
| 2671 | if ((result->m_flags & M_PKTHDR) == 0) |
| 2672 | goto fail; |
| 2673 | |
| 2674 | if (result->m_len < sizeof(struct sadb_msg)) { |
| 2675 | result = m_pullup(result, sizeof(struct sadb_msg)); |
| 2676 | if (result == NULL) |
| 2677 | goto fail; |
| 2678 | } |
| 2679 | |
| 2680 | result->m_pkthdr.len = 0; |
| 2681 | for (m = result; m; m = m->m_next) |
no test coverage detected