Open Source Telephony
 help / color / mirror / Atom feed
From: Gustavo F. Padovan <gustavo@padovan.org>
To: ofono@ofono.org
Subject: Re: [PATCH] ppp: silently discard packets if needed
Date: Tue, 27 Apr 2010 18:12:03 -0300	[thread overview]
Message-ID: <20100427211203.GD5070@vigoh> (raw)
In-Reply-To: <1272400009-29082-1-git-send-email-kristen@linux.intel.com>

[-- Attachment #1: Type: text/plain, Size: 2001 bytes --]

Hi Kristen,

* Kristen Carlson Accardi <kristen@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.

> +	case PPP_PHASE_NETWORK:
> +		break;
> +	}
> +
> +	return FALSE;
> +}
> +
>  /* called when we have received a complete ppp frame */
>  static void ppp_recv(GAtPPP *ppp, struct frame_buffer *frame)
>  {
>  	guint16 protocol = ppp_proto(frame->bytes);
>  	guint8 *packet = ppp_info(frame->bytes);
>  
> -	/*
> -	 * Any non-LCP packets received during Link Establishment
> -	 * phase must be silently discarded.
> -	 */
> -	if (ppp->phase == PPP_PHASE_ESTABLISHMENT && protocol != LCP_PROTOCOL)
> +	if (drop_packet(ppp, protocol))
>  		return;
>  
>  	switch (protocol) {
> -- 
> 1.6.6.1
> 
> _______________________________________________
> ofono mailing list
> ofono(a)ofono.org
> http://lists.ofono.org/listinfo/ofono

-- 
Gustavo F. Padovan
http://padovan.org

  reply	other threads:[~2010-04-27 21:12 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-27 20:26 [PATCH] ppp: silently discard packets if needed Kristen Carlson Accardi
2010-04-27 21:12 ` Gustavo F. Padovan [this message]
2010-04-27 21:45   ` Kristen Carlson Accardi
  -- strict thread matches above, loose matches on Subject: below --
2010-04-27 21:53 Kristen Carlson Accardi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100427211203.GD5070@vigoh \
    --to=gustavo@padovan.org \
    --cc=ofono@ofono.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox