kernels/linux-2.4.0/drivers/net/ppp_generic.c
/*
 * Look at a CCP packet and update our state accordingly.
 * We assume the caller has the xmit or recv path locked.
 */
Look at a CCP packet and update our state accordingly.
We assume the caller has the xmit or recv path locked.
Look at a CCP packet and update our state accordingly . We assume the caller has the xmit or recv path locked .
static void
ppp_ccp_peek(struct ppp *ppp, struct sk_buff *skb, int inbound)
{
	unsigned char *dp = skb->data + 2;
	int len;
	if (skb->len < CCP_HDRLEN + 2
	    || skb->len < (len = CCP_LENGTH(dp)) + 2)
		return;		
	switch (CCP_CODE(dp)) {
	case CCP_CONFREQ:
	case CCP_TERMREQ:
	case CCP_TERMACK:
		if (inbound)
			ppp->rstate &= ~SC_DECOMP_RUN;
		else
			ppp->xstate &= ~SC_COMP_RUN;
		break;
	case CCP_CONFACK:
		if ((ppp->flags & (SC_CCP_OPEN | SC_CCP_UP)) != SC_CCP_OPEN)
			break;
		dp += CCP_HDRLEN;
		len -= CCP_HDRLEN;
		if (len < CCP_OPT_MINLEN || len < CCP_OPT_LENGTH(dp))
			break;
		if (inbound) {
			if (ppp->rc_state == 0)
				break;
			if (ppp->rcomp->decomp_init(ppp->rc_state, dp, len,
					ppp->file.index, 0, ppp->mru, ppp->debug)) {
				ppp->rstate |= SC_DECOMP_RUN;
				ppp->rstate &= ~(SC_DC_ERROR | SC_DC_FERROR);
			}
		} else {
			if (ppp->xc_state == 0)
				break;
			if (ppp->xcomp->comp_init(ppp->xc_state, dp, len,
					ppp->file.index, 0, ppp->debug))
				ppp->xstate |= SC_COMP_RUN;
		}
		break;
	case CCP_RESETACK:
		if ((ppp->flags & SC_CCP_UP) == 0)
			break;
		if (inbound) {
			if (ppp->rc_state && (ppp->rstate & SC_DECOMP_RUN)) {
				ppp->rcomp->decomp_reset(ppp->rc_state);
				ppp->rstate &= ~SC_DC_ERROR;
			}
		} else {
			if (ppp->xc_state && (ppp->xstate & SC_COMP_RUN))
				ppp->xcomp->comp_reset(ppp->xc_state);
		}
		break;
	}
}
static void ppp_ccp_peek ( struct ppp * ppp , struct sk_buff * skb , int inbound ) { unsigned char * dp = skb -> data + 2 ; int len ; if ( skb -> len < CCP_HDRLEN + 2 || skb -> len < ( len = CCP_LENGTH ( dp ) ) + 2 ) return ; switch ( CCP_CODE ( dp ) ) { case CCP_CONFREQ : case CCP_TERMREQ : case CCP_TERMACK : if ( inbound ) ppp -> rstate &= ~ SC_DECOMP_RUN ; else ppp -> xstate &= ~ SC_COMP_RUN ; break ; case CCP_CONFACK : if ( ( ppp -> flags & ( SC_CCP_OPEN | SC_CCP_UP ) ) != SC_CCP_OPEN ) break ; dp += CCP_HDRLEN ; len -= CCP_HDRLEN ; if ( len < CCP_OPT_MINLEN || len < CCP_OPT_LENGTH ( dp ) ) break ; if ( inbound ) { if ( ppp -> rc_state == 0 ) break ; if ( ppp -> rcomp -> decomp_init ( ppp -> rc_state , dp , len , ppp -> file . index , 0 , ppp -> mru , ppp -> debug ) ) { ppp -> rstate |= SC_DECOMP_RUN ; ppp -> rstate &= ~ ( SC_DC_ERROR | SC_DC_FERROR ) ; } } else { if ( ppp -> xc_state == 0 ) break ; if ( ppp -> xcomp -> comp_init ( ppp -> xc_state , dp , len , ppp -> file . index , 0 , ppp -> debug ) ) ppp -> xstate |= SC_COMP_RUN ; } break ; case CCP_RESETACK : if ( ( ppp -> flags & SC_CCP_UP ) == 0 ) break ; if ( inbound ) { if ( ppp -> rc_state && ( ppp -> rstate & SC_DECOMP_RUN ) ) { ppp -> rcomp -> decomp_reset ( ppp -> rc_state ) ; ppp -> rstate &= ~ SC_DC_ERROR ; } } else { if ( ppp -> xc_state && ( ppp -> xstate & SC_COMP_RUN ) ) ppp -> xcomp -> comp_reset ( ppp -> xc_state ) ; } break ; } }
Look at a CCP packet and update our state accordingly.
Look at a CCP packet and update our state accordingly .
/* too short */ /*
		 * CCP is going down - disable compression.
		 */ /* we will start receiving compressed packets */ /* we will soon start sending compressed packets */ /* reset the [de]compressor */