X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=modules%2Fppp_ahdlc.c;h=1828fe1e96fb40a1f20a48eb0267975aad083178;hb=799c9cfba45ffc770212c24d16887b8581da6010;hp=ba4f41c126b6276c31b64fe844118d6b3797e59d;hpb=a44a616baa968a263dc273bc06ed79c475b7deec;p=ppp.git diff --git a/modules/ppp_ahdlc.c b/modules/ppp_ahdlc.c index ba4f41c..1828fe1 100644 --- a/modules/ppp_ahdlc.c +++ b/modules/ppp_ahdlc.c @@ -24,11 +24,11 @@ * OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, * OR MODIFICATIONS. * - * $Id: ppp_ahdlc.c,v 1.1 1995/12/11 05:06:42 paulus Exp $ + * $Id: ppp_ahdlc.c,v 1.11 1999/09/15 23:49:05 masputra Exp $ */ /* - * This file is used under Solaris 2, SVR4, SunOS 4, and OSF/1. + * This file is used under Solaris 2, SVR4, SunOS 4, and Digital UNIX. */ #include #include @@ -42,6 +42,9 @@ #include #else #include +#ifdef __osf__ +#include +#endif #endif /* SVR4 */ #include @@ -66,8 +69,13 @@ static int msg_byte __P((mblk_t *, unsigned int)); /* Is this LCP packet one we have to transmit using LCP defaults? */ #define LCP_USE_DFLT(mp) (1 <= (code = MSG_BYTE((mp), 4)) && code <= 7) +#define PPP_AHDL_ID 0x7d23 static struct module_info minfo = { - 0x7d23, "ppp_ahdl", 0, INFPSZ, 4096, 128 +#ifdef PRIOQ + PPP_AHDL_ID, "ppp_ahdl", 0, INFPSZ, 640, 512 +#else + PPP_AHDL_ID, "ppp_ahdl", 0, INFPSZ, 4096, 128 +#endif PRIOQ }; static struct qinit rinit = { @@ -78,6 +86,10 @@ static struct qinit winit = { ahdlc_wput, NULL, NULL, NULL, NULL, &minfo, NULL }; +#if defined(SVR4) && !defined(SOL2) +int phdldevflag = 0; +#define ppp_ahdlcinfo phdlinfo +#endif struct streamtab ppp_ahdlcinfo = { &rinit, &winit, NULL, NULL }; @@ -159,7 +171,7 @@ MOD_OPEN(ahdlc_open) WR(q)->q_ptr = (caddr_t) sp; sp->xaccm[0] = ~0; sp->xaccm[3] = 0x60000000; - sp->mru = 1500; + sp->mru = PPP_MRU; ++ppp_ahdlc_count; qprocson(q); } @@ -178,6 +190,8 @@ MOD_CLOSE(ahdlc_close) state->cur_frame = 0; } FREE(q->q_ptr, sizeof(ahdlc_state_t)); + q->q_ptr = NULL; + OTHERQ(q)->q_ptr = NULL; --ppp_ahdlc_count; } return 0; @@ -195,6 +209,12 @@ ahdlc_wput(q, mp) struct ppp_stats *psp; state = (ahdlc_state_t *) q->q_ptr; + if (state == 0) { + DPRINT("state == 0 in ahdlc_wput\n"); + freemsg(mp); + return 0; + } + switch (mp->b_datap->db_type) { case M_DATA: /* @@ -213,9 +233,13 @@ ahdlc_wput(q, mp) if (iop->ioc_count < sizeof(u_int32_t) || iop->ioc_count > sizeof(ext_accm)) break; + if (mp->b_cont == 0) { + DPRINT1("ahdlc_wput/%d: PPPIO_XACCM b_cont = 0!\n", state->unit); + break; + } bcopy((caddr_t)mp->b_cont->b_rptr, (caddr_t)state->xaccm, iop->ioc_count); - state->xaccm[2] &= 0x40000000; /* don't escape 0x5e */ + state->xaccm[2] &= ~0x40000000; /* don't escape 0x5e */ state->xaccm[3] |= 0x60000000; /* do escape 0x7d, 0x7e */ iop->ioc_count = 0; error = 0; @@ -224,6 +248,10 @@ ahdlc_wput(q, mp) case PPPIO_RACCM: if (iop->ioc_count != sizeof(u_int32_t)) break; + if (mp->b_cont == 0) { + DPRINT1("ahdlc_wput/%d: PPPIO_RACCM b_cont = 0!\n", state->unit); + break; + } bcopy((caddr_t)mp->b_cont->b_rptr, (caddr_t)&state->raccm, sizeof(u_int32_t)); iop->ioc_count = 0; @@ -306,6 +334,7 @@ ahdlc_wput(q, mp) default: putnext(q, mp); } + return 0; } @@ -314,10 +343,15 @@ ahdlc_rput(q, mp) queue_t *q; mblk_t *mp; { - mblk_t *np; - uchar_t *cp; ahdlc_state_t *state; + state = (ahdlc_state_t *) q->q_ptr; + if (state == 0) { + DPRINT("state == 0 in ahdlc_rput\n"); + freemsg(mp); + return 0; + } + switch (mp->b_datap->db_type) { case M_DATA: unstuff_chars(q, mp); @@ -325,7 +359,6 @@ ahdlc_rput(q, mp) break; case M_HANGUP: - state = (ahdlc_state_t *) q->q_ptr; if (state->cur_frame != 0) { /* XXX would like to send this up for debugging */ freemsg(state->cur_frame); @@ -352,13 +385,11 @@ stuff_frame(q, mp) mblk_t *mp; { ahdlc_state_t *state; - int ilen, olen, c, extra, i, code; + int ilen, olen, c, extra, code; mblk_t *omsg, *op, *np; uchar_t *sp, *sp0, *dp, *dp0, *spend; ushort_t fcs; u_int32_t *xaccm, lcp_xaccm[8]; - static uchar_t lcphdr[PPP_HDRLEN] = { 0xff, 0x03, 0xc0, 0x21 }; - uchar_t ppphdr[PPP_HDRLEN]; state = (ahdlc_state_t *) q->q_ptr; ilen = msgdsize(mp); @@ -375,12 +406,14 @@ stuff_frame(q, mp) goto bomb; /* - * Put in an initial flag for now. We'll remove it later - * if we decide we don't need it. + * Put in an initial flag, unless the serial driver currently has + * packets still to be transmitted in its queue. */ dp = op->b_wptr; - *dp++ = PPP_FLAG; - --olen; + if (qsize(q->q_next) == 0) { + *dp++ = PPP_FLAG; + --olen; + } /* * For LCP packets with code values between 1 and 7 (Conf-Req @@ -492,12 +525,6 @@ stuff_frame(q, mp) *dp++ = PPP_FLAG; op->b_wptr = dp; - /* - * Remove the initial flag, if possible. - */ - if (qsize(q->q_next) > 0) - ++omsg->b_rptr; - /* * Update statistics. */ @@ -539,7 +566,7 @@ unstuff_chars(q, mp) ahdlc_state_t *state; mblk_t *om; uchar_t *cp, *cpend, *dp, *dp0; - int c, len, extra, offset; + int c, len, extra; ushort_t fcs; state = (ahdlc_state_t *) q->q_ptr; @@ -623,10 +650,11 @@ unstuff_chars(q, mp) putnext(q, om); /* bombs away! */ continue; } - DPRINT1("ppp_ahdl: bad fcs %x\n", state->infcs); + DPRINT2("ppp%d: bad fcs (len=%d)\n", state->unit, len); } if (om != 0) freemsg(om); + state->flags &= ~(IFLUSH|ESCAPED); state->stats.ppp_ierrors++; putctl1(q->q_next, M_CTL, PPPCTL_IERROR); continue; @@ -662,7 +690,8 @@ unstuff_chars(q, mp) */ if (state->inlen >= state->mru + PPP_HDRLEN + PPP_FCSLEN) { state->flags |= IFLUSH; - DPRINT1("ppp_ahdl: frame too long (%d)\n", state->inlen); + DPRINT2("ppp%d: frame too long (%d)\n", + state->unit, state->inlen); continue; } om = allocb(IFRAME_BSIZE, BPRI_MED);