MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ng_mppc_decompress

Function ng_mppc_decompress

freebsd/netgraph/ng_mppc.c:625–836  ·  view source on GitHub ↗

* Decompress/decrypt packet and put the result in a new mbuf at *resultp. * The original mbuf is not free'd. */

Source from the content-addressed store, hash-verified

623 * The original mbuf is not free'd.
624 */
625static int
626ng_mppc_decompress(node_p node, struct mbuf **datap)
627{
628 const priv_p priv = NG_NODE_PRIVATE(node);
629 struct ng_mppc_dir *const d = &priv->recv;
630 u_int16_t header, cc;
631 u_int numLost;
632 struct mbuf *m = *datap;
633
634 /* We must own the mbuf chain exclusively to modify it. */
635 m = m_unshare(m, M_NOWAIT);
636 if (m == NULL)
637 return (ENOMEM);
638
639 /* Pull off header */
640 if (m->m_pkthdr.len < MPPC_HDRLEN) {
641 m_freem(m);
642 return (EINVAL);
643 }
644 header = be16dec(mtod(m, void *));
645 cc = (header & MPPC_CCOUNT_MASK);
646 m_adj(m, MPPC_HDRLEN);
647
648 /* Check for an unexpected jump in the sequence number */
649 numLost = ((cc - d->cc) & MPPC_CCOUNT_MASK);
650
651 /* If flushed bit set, we can always handle packet */
652 if ((header & MPPC_FLAG_FLUSHED) != 0) {
653#ifdef NETGRAPH_MPPC_COMPRESSION
654 if (d->history != NULL)
655 MPPC_InitDecompressionHistory(d->history);
656#endif
657#ifdef NETGRAPH_MPPC_ENCRYPTION
658 if ((d->cfg.bits & MPPE_BITS) != 0) {
659 u_int rekey;
660
661 /* How many times are we going to have to re-key? */
662 rekey = ((d->cfg.bits & MPPE_STATELESS) != 0) ?
663 numLost : (numLost / (MPPE_UPDATE_MASK + 1));
664 if (rekey > mppe_max_rekey) {
665 if (mppe_block_on_max_rekey) {
666 if (mppe_log_max_rekey) {
667 log(LOG_ERR, "%s: too many (%d) packets"
668 " dropped, disabling node %p!\n",
669 __func__, numLost, node);
670 }
671 priv->recv.cfg.enable = 0;
672 goto failed;
673 } else {
674 if (mppe_log_max_rekey) {
675 log(LOG_ERR, "%s: %d packets"
676 " dropped, node %p\n",
677 __func__, numLost, node);
678 }
679 goto failed;
680 }
681 }
682

Callers 1

ng_mppc_rcvdataFunction · 0.85

Calls 14

m_unshareFunction · 0.85
be16decFunction · 0.85
m_adjFunction · 0.85
ng_mppc_updatekeyFunction · 0.85
rc4_initFunction · 0.85
rc4_cryptFunction · 0.85
mallocFunction · 0.85
m_copydataFunction · 0.85
MPPC_DecompressFunction · 0.85
m_copybackFunction · 0.85
m_freemFunction · 0.50

Tested by

no test coverage detected