[PATCH] ppp: silently discard packets if needed

Kristen Carlson Accardi kristen at linux.intel.com
Tue Apr 27 14:45:04 PDT 2010


On Tue, 27 Apr 2010 18:12:03 -0300
"Gustavo F. Padovan" <gustavo at padovan.org> wrote:

> Hi Kristen,
> 
> * Kristen Carlson Accardi <kristen at linux.intel.com> [2010-04-27 13:26:49 -0700]:
> 
> > When receiving a packet, check the protocol and the phase to see
> > if the packet should be dropped.
> > ---
> >  gatchat/gatppp.c |   31 ++++++++++++++++++++++++++-----
> >  1 files changed, 26 insertions(+), 5 deletions(-)
> > 
> > diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
> > index c7bf089..933cbec 100644
> > --- a/gatchat/gatppp.c
> > +++ b/gatchat/gatppp.c
> > @@ -173,17 +173,38 @@ static struct frame_buffer *ppp_encode(GAtPPP *ppp, guint8 *data, int len)
> >  	return fb;
> >  }
> >  
> > +/*
> > + * Silently discard packets which are received when they shouldn't be
> > + */
> > +static inline gboolean drop_packet(GAtPPP *ppp, guint16 protocol)
> > +{
> > +	switch (ppp->phase) {
> > +	case PPP_PHASE_ESTABLISHMENT:
> > +	case PPP_PHASE_TERMINATION:
> > +		if (protocol != LCP_PROTOCOL)
> > +			return TRUE;
> > +		break;
> > +	case PPP_PHASE_AUTHENTICATION:
> > +		if (protocol != LCP_PROTOCOL && protocol != CHAP_PROTOCOL)
> > +			return TRUE;
> > +		break;
> > +	case PPP_PHASE_DEAD:
> > +		return TRUE;
> > +		break;
> 
> You have a return and a break on the same case. You'll never reach the
> break here.

whoops - forgot to delete that.  Thanks, will resend.


More information about the ofono mailing list