* OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
* OR MODIFICATIONS.
*
- * $Id: ppp_ahdlc.c,v 1.3 1995/05/29 06:45:49 paulus Exp $
+ * $Id: ppp_ahdlc.c,v 1.5 1995/10/27 03:57:10 paulus Exp $
*/
/*
0x69969669, 0x96696996, 0x96696996, 0x69969669
};
+#define UPDATE_FLAGS(c) { \
+ if ((c) & 0x80) \
+ state->flags |= RCV_B7_1; \
+ else \
+ state->flags |= RCV_B7_0; \
+ if (paritytab[(c) >> 5] & (1 << ((c) & 0x1F))) \
+ state->flags |= RCV_ODDP; \
+ else \
+ state->flags |= RCV_EVNP; \
+}
+
/*
* Process received characters.
*/
}
if ((state->flags & (IFLUSH|ESCAPED)) == 0
- && state->inlen >= PPP_HDRLEN
- && (om = state->cur_blk) != 0) {
+ && state->inlen > 0 && (om = state->cur_blk) != 0) {
/*
* Process bulk chars as quickly as possible.
*/
if (c == PPP_FLAG)
break;
++cp;
- if (c & 0x80)
- state->flags |= RCV_B7_1;
- else
- state->flags |= RCV_B7_0;
- if (paritytab[c >> 5] & (1 << (c & 0x1F)))
- state->flags |= RCV_ODDP;
- else
- state->flags |= RCV_EVNP;
+ UPDATE_FLAGS(c);
if (c == PPP_ESCAPE) {
if (extra > 0) {
--extra;
++cpend;
- } else if (cp >= cpend) {
+ }
+ if (cp >= cpend || (c = *cp) == PPP_FLAG) {
state->flags |= ESCAPED;
break;
}
- c = *cp;
- if (c == PPP_FLAG)
- break;
++cp;
+ UPDATE_FLAGS(c);
c ^= PPP_TRANS;
}
*dp++ = c;
state->inlen += dp - dp0;
state->infcs = fcs;
om->b_wptr = dp;
- if (cp >= cpend)
- continue; /* go back and check cp again */
+ if (cp >= mp->b_wptr)
+ continue; /* advance to the next mblk */
}
c = *cp++;
- if (c & 0x80)
- state->flags |= RCV_B7_1;
- else
- state->flags |= RCV_B7_0;
- if (paritytab[c >> 5] & (1 << (c & 0x1F)))
- state->flags |= RCV_ODDP;
- else
- state->flags |= RCV_EVNP;
+ UPDATE_FLAGS(c);
if (c == PPP_FLAG) {
/*
* End of a frame.
state->cur_blk = om;
}
}
- *om->b_wptr++ = c;
- ++state->inlen;
- state->infcs = PPP_FCS(state->infcs, c);
- if (state->inlen == PPP_HDRLEN) {
+ if (state->inlen == 0) {
/*
* We don't do address/control & protocol decompression here,
- * but we do leave space for the decompressed fields and
- * arrange for the info field to start on a word boundary.
+ * but we try to put the first byte at an offset such that
+ * the info field starts on a word boundary. The code here
+ * will do this except for packets with protocol compression
+ * but not address/control compression.
*/
- dp = om->b_rptr;
- if (PPP_ADDRESS(dp) == PPP_ALLSTATIONS
- && PPP_CONTROL(dp) == PPP_UI)
- dp += 2;
- if ((*dp & 1) == 0)
- ++dp;
- /* dp is now pointing at the last byte of the ppp protocol field */
- offset = 3 - ((unsigned)dp & 3);
- if (offset > 0) {
- dp = om->b_wptr;
- do {
- --dp;
- dp[offset] = dp[0];
- } while (dp > om->b_rptr);
- om->b_rptr += offset;
- om->b_wptr += offset;
+ if (c != PPP_ALLSTATIONS) {
+ om->b_wptr += 2;
+ if (c & 1)
+ ++om->b_wptr;
+ om->b_rptr = om->b_wptr;
}
}
+
+ *om->b_wptr++ = c;
+ ++state->inlen;
+ state->infcs = PPP_FCS(state->infcs, c);
}
}