- if (!ppp || ppp->magic != PPP_MAGIC) {
- if (ppp->flags & SC_DEBUG)
- printk (KERN_DEBUG
- "PPP: handler called but couldn't find "
- "PPP struct.\n");
- return;
- }
- CHECK_PPP_VOID ();
-/*
- * Print the buffer if desired
- */
- if (ppp->flags & SC_LOG_RAWIN)
- ppp_print_buffer ("receive buffer", data, count);
-/*
- * Collect the character and error condition for the character. Set the toss
- * flag for the first character error.
- */
- while (count-- > 0) {
- ppp->bytes_rcvd++;
- chr = *data++;
- if (flags) {
- if (*flags && ppp->toss == 0)
- ppp->toss = *flags;
- ++flags;
- }
-/*
- * Set the flags for 8 data bits and no parity.
- *
- * Actually, it sets the flags for d7 being 0/1 and parity being even/odd
- * so that the normal processing would have all flags set at the end of the
- * session. A missing flag bit would denote an error condition.
- */
-
-#ifdef CHECK_CHARACTERS
- if (chr & 0x80)
- ppp->flags |= SC_RCV_B7_1;
- else
- ppp->flags |= SC_RCV_B7_0;
-
- if (paritytab[chr >> 5] & (1 << (chr & 0x1F)))
- ppp->flags |= SC_RCV_ODDP;
- else
- ppp->flags |= SC_RCV_EVNP;
-#endif
-/*
- * Branch on the character. Process the escape character. The sequence ESC ESC
- * is defined to be ESC.
- */
- switch (chr) {
- case PPP_ESCAPE: /* PPP_ESCAPE: invert bit in next character */
- ppp->escape = PPP_TRANS;
- break;
-/*
- * FLAG. This is the end of the block. If the block terminated by ESC FLAG,
- * then the block is to be ignored. In addition, characters before the very
- * first FLAG are also tossed by this procedure.
- */
- case PPP_FLAG: /* PPP_FLAG: end of frame */
- ppp->stats.ppp_ibytes = ppp->bytes_rcvd;
- if (ppp->escape)
- ppp->toss |= 0x80;
-/*
- * Process frames which are not to be ignored. If the processing failed,
- * then clean up the VJ tables.
- */
- if ((ppp->toss & 0x80) != 0 ||
- ppp_doframe (ppp) == 0) {
- slhc_toss (ppp->slcomp);
- }
-/*
- * Reset all indicators for the new frame to follow.
- */
- buf->count = 0;
- buf->fcs = PPP_INITFCS;
- ppp->escape = 0;
- ppp->toss = 0;
- break;
-/*
- * All other characters in the data come here. If the character is in the
- * receive mask then ignore the character.
- */
- default:
- if (in_rmap (ppp, chr))
- break;
-/*
- * Adjust the character and if the frame is to be discarded then simply
- * ignore the character until the ending FLAG is received.
- */
- chr ^= ppp->escape;
- ppp->escape = 0;
-
- if (ppp->toss != 0)
- break;
-/*
- * If the count sent is within reason then store the character, bump the
- * count, and update the FCS for the character.
- */
- if (buf->count < buf->size) {
- buf_base (buf)[buf->count++] = chr;
- buf->fcs = PPP_FCS (buf->fcs, chr);
- break;
- }
-/*
- * The peer sent too much data. Set the flags to discard the current frame
- * and wait for the re-synchronization FLAG to be sent.
- */
- ppp->stats.ppp_ierrors++;
- ppp->toss |= 0xC0;
- break;
- }
- }
-}
-
-/*
- * Put the input frame into the networking system for the indicated protocol
- */
-