* Pull a completed packet off the head of the incoming fragment queue. * This assumes there is a completed packet there to pull off. */
| 1703 | * This assumes there is a completed packet there to pull off. |
| 1704 | */ |
| 1705 | static void |
| 1706 | ng_ppp_get_packet(node_p node, struct mbuf **mp) |
| 1707 | { |
| 1708 | const priv_p priv = NG_NODE_PRIVATE(node); |
| 1709 | struct ng_ppp_frag *qent, *qnext; |
| 1710 | struct mbuf *m = NULL, *tail; |
| 1711 | |
| 1712 | qent = TAILQ_FIRST(&priv->frags); |
| 1713 | KASSERT(!TAILQ_EMPTY(&priv->frags) && qent->first, |
| 1714 | ("%s: no packet", __func__)); |
| 1715 | for (tail = NULL; qent != NULL; qent = qnext) { |
| 1716 | qnext = TAILQ_NEXT(qent, f_qent); |
| 1717 | KASSERT(!TAILQ_EMPTY(&priv->frags), |
| 1718 | ("%s: empty q", __func__)); |
| 1719 | TAILQ_REMOVE(&priv->frags, qent, f_qent); |
| 1720 | if (tail == NULL) |
| 1721 | tail = m = qent->data; |
| 1722 | else { |
| 1723 | m->m_pkthdr.len += qent->data->m_pkthdr.len; |
| 1724 | tail->m_next = qent->data; |
| 1725 | } |
| 1726 | while (tail->m_next != NULL) |
| 1727 | tail = tail->m_next; |
| 1728 | if (qent->last) { |
| 1729 | qnext = NULL; |
| 1730 | /* Bump MSEQ if necessary */ |
| 1731 | ng_ppp_bump_mseq(node, qent->seq); |
| 1732 | } |
| 1733 | TAILQ_INSERT_HEAD(&priv->fragsfree, qent, f_qent); |
| 1734 | } |
| 1735 | *mp = m; |
| 1736 | } |
| 1737 | |
| 1738 | /* |
| 1739 | * Trim fragments from the queue whose packets can never be completed. |
no test coverage detected