* Run the queue, restoring the queue invariants */
| 1821 | * Run the queue, restoring the queue invariants |
| 1822 | */ |
| 1823 | static int |
| 1824 | ng_ppp_frag_process(node_p node, item_p oitem) |
| 1825 | { |
| 1826 | const priv_p priv = NG_NODE_PRIVATE(node); |
| 1827 | struct mbuf *m; |
| 1828 | item_p item; |
| 1829 | uint16_t proto; |
| 1830 | |
| 1831 | do { |
| 1832 | /* Deliver any deliverable packets */ |
| 1833 | while (ng_ppp_check_packet(node)) { |
| 1834 | ng_ppp_get_packet(node, &m); |
| 1835 | if ((m = ng_ppp_cutproto(m, &proto)) == NULL) |
| 1836 | continue; |
| 1837 | if (!PROT_VALID(proto)) { |
| 1838 | priv->bundleStats.badProtos++; |
| 1839 | NG_FREE_M(m); |
| 1840 | continue; |
| 1841 | } |
| 1842 | if (oitem) { /* If original item present - reuse it. */ |
| 1843 | item = oitem; |
| 1844 | oitem = NULL; |
| 1845 | NGI_M(item) = m; |
| 1846 | } else { |
| 1847 | item = ng_package_data(m, NG_NOFLAGS); |
| 1848 | } |
| 1849 | if (item != NULL) { |
| 1850 | /* Stats */ |
| 1851 | priv->bundleStats.recvFrames++; |
| 1852 | priv->bundleStats.recvOctets += |
| 1853 | NGI_M(item)->m_pkthdr.len; |
| 1854 | |
| 1855 | /* Drop mutex for the sending time. |
| 1856 | * Priv may change, but we are ready! |
| 1857 | */ |
| 1858 | mtx_unlock(&priv->rmtx); |
| 1859 | ng_ppp_crypt_recv(node, item, proto, |
| 1860 | NG_PPP_BUNDLE_LINKNUM); |
| 1861 | mtx_lock(&priv->rmtx); |
| 1862 | } |
| 1863 | } |
| 1864 | /* Delete dead fragments and try again */ |
| 1865 | } while (ng_ppp_frag_trim(node) || ng_ppp_frag_drop(node)); |
| 1866 | |
| 1867 | /* If we haven't reused original item - free it. */ |
| 1868 | if (oitem) NG_FREE_ITEM(oitem); |
| 1869 | |
| 1870 | /* Done */ |
| 1871 | return (0); |
| 1872 | } |
| 1873 | |
| 1874 | /* |
| 1875 | * Check for 'stale' completed packets that need to be delivered |
no test coverage detected