ppp: silently discard packets if needed
PATCH 1/1 ppp: silently discard packets if needed
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(-)
gatchat/gatppp.c +26 -5
@@ -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) {
Signature · 1 line
1.6.6.1
Hi Kristen,
Quoted 22 lines · Kristen Carlson Accardi
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(-)gatchat/gatppp.c +8
-0@@ -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 :
gatchat/gatppp.c static struct frame_buffer *ppp_encode(GAtPPP *ppp, guint8 *data, int len) · line 193
Quoted 10 lines
gatchat/gatppp.c +10
-0+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.
Quoted 29 lines
gatchat/gatppp.c +8
-5+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) {Signature · 6 lines
1.6.6.1 _______________________________________________ ofono mailing list ofono(a)ofono.org http://lists.ofono.org/listinfo/ofono
Signature · 2 lines
Gustavo F. Padovan http://padovan.org
Quoted 31 lines · On Tue, 27 Apr 2010 18:12:03 -0300 "Gustavo F. Padovan" <[email protected]>…
Hi Kristen,
Quoted 27 lines · Kristen Carlson Accardi
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(-)gatchat/gatppp.c +13
-0@@ -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 )
Quoted 8 lines
gatchat/gatppp.c static struct frame_buffer *ppp_encode(GAtPPP *ppp, guint8 *data, int len) · line 193
Quoted 5 lines
gatchat/gatppp.c +5
-0+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.