All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ppp: silently discard packets if needed
@ 2010-04-27 20:26 Kristen Carlson Accardi
  2010-04-27 21:12 ` Gustavo F. Padovan
  0 siblings, 1 reply; 4+ messages in thread
From: Kristen Carlson Accardi @ 2010-04-27 20:26 UTC (permalink / raw)
  To: ofono

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

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;
+	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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] ppp: silently discard packets if needed
  2010-04-27 20:26 [PATCH] ppp: silently discard packets if needed Kristen Carlson Accardi
@ 2010-04-27 21:12 ` Gustavo F. Padovan
  2010-04-27 21:45   ` Kristen Carlson Accardi
  0 siblings, 1 reply; 4+ messages in thread
From: Gustavo F. Padovan @ 2010-04-27 21:12 UTC (permalink / raw)
  To: ofono

[-- 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] ppp: silently discard packets if needed
  2010-04-27 21:12 ` Gustavo F. Padovan
@ 2010-04-27 21:45   ` Kristen Carlson Accardi
  0 siblings, 0 replies; 4+ messages in thread
From: Kristen Carlson Accardi @ 2010-04-27 21:45 UTC (permalink / raw)
  To: ofono

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

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

> 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.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ppp: silently discard packets if needed
@ 2010-04-27 21:53 Kristen Carlson Accardi
  0 siblings, 0 replies; 4+ messages in thread
From: Kristen Carlson Accardi @ 2010-04-27 21:53 UTC (permalink / raw)
  To: ofono

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

When receiving a packet, check the protocol and the phase to see
if the packet should be dropped.
---
 gatchat/gatppp.c |   30 +++++++++++++++++++++++++-----
 1 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index c7bf089..e51c281 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -173,17 +173,37 @@ 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;
+	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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-04-27 21:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-27 20:26 [PATCH] ppp: silently discard packets if needed Kristen Carlson Accardi
2010-04-27 21:12 ` Gustavo F. Padovan
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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.