-static void ppp_doframe_lower (struct ppp *ppp, __u8 *data, int count)
-{
- __u16 proto = PPP_PROTOCOL (data);
- ppp_proto_type *proto_ptr;
-/*
- * Ignore empty frames
- */
- if (count <= PPP_HDRLEN)
- return;
-/*
- * Count the frame and print it
- */
- ++ppp->stats.ppp_ipackets;
- if (ppp->flags & SC_LOG_INPKT)
- ppp_print_buffer ("receive frame", data, count);
-/*
- * Find the procedure to handle this protocol. The last one is marked
- * as a protocol 0 which is the 'catch-all' to feed it to the pppd daemon.
- */
- proto_ptr = proto_list;
- while (proto_ptr->proto != 0 && proto_ptr->proto != proto)
- ++proto_ptr;
-/*
- * Update the appropriate statistic counter.
- */
- if ((*proto_ptr->func) (ppp, proto,
- &data[PPP_HARD_HDR_LEN],
- count - PPP_HARD_HDR_LEN))
- ppp->stats.ppp_ioctects += count;
- else
- ++ppp->stats.ppp_discards;
-}
-
-/* on entry, a received frame is in ppp->rbuf.bufr
- check it and dispose as appropriate */
-
-static int
-ppp_doframe (struct ppp *ppp)
-{
- __u8 *data = buf_base (ppp->rbuf);
- int count = ppp->rbuf->count;
- int addr, ctrl, proto;
- int new_count;
- __u8 *new_data;
-/*
- * If there is a pending error from the receiver then log it and discard
- * the damaged frame.
- */
- if (ppp->toss) {
- if ((ppp->flags & SC_DEBUG) && count > 0)
- printk (KERN_DEBUG
- "ppp_toss: tossing frame, reason = %x\n",
- ppp->toss);
- return 0;
- }
-/*
- * An empty frame is ignored. This occurs if the FLAG sequence precedes and
- * follows each frame.
- */
- if (count == 0)
- return 1;
-/*
- * Generate an error if the frame is too small.
- */
- if (count < PPP_HARD_HDR_LEN) {
- if (ppp->flags & SC_DEBUG)
- printk (KERN_DEBUG
- "ppp: got runt ppp frame, %d chars\n", count);
- ++ppp->estats.rx_length_errors;
- return 0;
- }
-/*
- * Verify the CRC of the frame and discard the CRC characters from the
- * end of the buffer.
- */
- if (ppp->rbuf->fcs != PPP_GOODFCS) {
- if (ppp->flags & SC_DEBUG) {
- printk (KERN_DEBUG
- "ppp: frame with bad fcs, length = %d\n",
- count);
- ppp_print_buffer("bad frame", data, count);
- }
- ++ppp->estats.rx_crc_errors;
- return 0;
- }
- count -= 2; /* ignore the fcs characters */
-/*
- * Ignore the leading ADDRESS and CONTROL fields in the frame.
- */
- addr = PPP_ALLSTATIONS;
- ctrl = PPP_UI;
-
- if ((data[0] == PPP_ALLSTATIONS) && (data[1] == PPP_UI)) {
- data += 2;
- count -= 2;
- }
-/*
- * Obtain the protocol from the frame
- */
- proto = (__u16) *data++;
- if ((proto & 1) == 0) {
- proto = (proto << 8) | (__u16) *data++;
- --count;
- }
-/*
- * Rewrite the header with the full information. This may encroach upon
- * the 'filler' area in the buffer header. This is the purpose for the
- * filler.
- */
- *(--data) = proto;
- *(--data) = proto >> 8;
- *(--data) = ctrl;
- *(--data) = addr;
- count += 3;
-/*
- * Process the active decompressor.
- */
- if ((ppp->sc_rc_state != (void *) 0) &&
- (ppp->flags & SC_DECOMP_RUN) &&
- ((ppp->flags & (SC_DC_FERROR | SC_DC_ERROR)) == 0)) {
- if (proto == PPP_COMP) {
-/*
- * If the frame is compressed then decompress it.
- */
- new_data = kmalloc (ppp->mru + PPP_HDRLEN, GFP_ATOMIC);
- if (new_data == NULL) {
- if (ppp->flags & SC_DEBUG)
- printk (KERN_ERR
- "ppp_doframe: no memory\n");
- new_count = DECOMP_ERROR;
- } else {
- new_count = (*ppp->sc_rcomp->decompress)
- (ppp->sc_rc_state, data, count,
- new_data, ppp->mru + PPP_HDRLEN);
- }
- switch (new_count) {
- default:
- ppp_doframe_lower (ppp, new_data, new_count);
- kfree (new_data);
- return 1;
-
- case DECOMP_ERROR:
- ppp->flags |= SC_DC_ERROR;
- break;
-
- case DECOMP_FATALERROR:
- ppp->flags |= SC_DC_FERROR;
- if (ppp->flags & SC_DEBUG)
- printk(KERN_ERR "ppp: fatal decomp error\n");
- break;
- }
-/*
- * Log the error condition and discard the frame.
- */
- if (new_data != 0)
- kfree (new_data);
- slhc_toss (ppp->slcomp);
- ++ppp->stats.ppp_ierrors;
- } else {
-/*
- * The frame is not special. Pass it through the compressor without
- * actually compressing the data
- */
- (*ppp->sc_rcomp->incomp) (ppp->sc_rc_state,
- data, count);
- }
- }
-/*
- * Process the uncompressed frame.
- */
- ppp_doframe_lower (ppp, data, count);
- return 1;
-}
-