- /*
- * The extra FRAME_END will start up a new packet, and thus
- * will flush any accumulated garbage. We do this whenever
- * the line may have been idle for some time.
- */
- if (flush)
- (void) putc(FRAME_END, &tp->t_outq);
-
- while (m != NULL) {
- len = m->m_len;
- mcp = mtod(m, u_char *);
- while (--len >= 0) {
- c = *mcp++;
- if (c == FRAME_ESCAPE || c == FRAME_END) {
- if (putc(FRAME_ESCAPE, &tp->t_outq))
- goto full;
- c = c == FRAME_ESCAPE ? TRANS_FRAME_ESCAPE :
- TRANS_FRAME_END;
- if (putc(c, &tp->t_outq)) {
- (void) unputc(&tp->t_outq);
- goto full;
+ /*
+ * Get a packet and send it to the interface.
+ */
+ s = splimp();
+ IF_DEQUEUE(&sc->sc_if.if_snd, m);
+ splx(s);
+ if (m == NULL)
+ return;
+
+ /*
+ * The extra FRAME_END will start up a new packet, and thus
+ * will flush any accumulated garbage. We do this whenever
+ * the line may have been idle for some time.
+ */
+ if (tp->t_outq.c_cc == 0)
+ (void) putc(FRAME_END, &tp->t_outq);
+
+ while (m) {
+ cp = mtod(m, u_char *);
+ len = m->m_len;
+ while (len > 0) {
+ /*
+ * Find out how many bytes in the string we can
+ * handle without doing something special.
+ */
+ nd = locc(FRAME_ESCAPE, len, cp);
+ np = locc(FRAME_END, len, cp);
+ n = len - MAX(nd, np);
+ if (n) {
+ /*
+ * Put n characters at once
+ * into the tty output queue.
+ */
+ if (b_to_q((char *)cp, n, &tp->t_outq))
+ break;
+ len -= n;
+ cp += n;