From: Kristen Carlson Accardi <kristen@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH] ppp: silently drop invalid packets
Date: Thu, 29 Apr 2010 12:18:29 -0700 [thread overview]
Message-ID: <1272568709-6812-1-git-send-email-kristen@linux.intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1697 bytes --]
---
gatchat/gatppp.c | 36 ++++++++++++++++++++++++++++--------
1 files changed, 28 insertions(+), 8 deletions(-)
diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index dfdaf40..6a2c30e 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -71,24 +71,44 @@ void ppp_debug(GAtPPP *ppp, const char *str)
ppp->debugf(str, ppp->debug_data);
}
+/*
+ * Silently discard packets which are received when they shouldn't be
+ */
+static inline gboolean ppp_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:
+ if (ppp->net == NULL)
+ return TRUE;
+ break;
+ }
+
+ return FALSE;
+}
+
static void ppp_receive(const unsigned char *buf, gsize len, void *data)
{
GAtPPP *ppp = data;
guint16 protocol = ppp_proto(buf);
const guint8 *packet = ppp_info(buf);
- /*
- * Any non-LCP packets received during Link Establishment
- * phase must be silently discarded.
- */
- if (ppp->phase == PPP_PHASE_ESTABLISHMENT && protocol != LCP_PROTOCOL)
+ if (ppp_drop_packet(ppp, protocol))
return;
switch (protocol) {
case PPP_IP_PROTO:
- /* If network is up & open, process the packet, if not, drop */
- if (ppp->net)
- ppp_net_process_packet(ppp->net, packet);
+ ppp_net_process_packet(ppp->net, packet);
break;
case LCP_PROTOCOL:
pppcp_process_packet(ppp->lcp, packet);
--
1.6.6.1
next reply other threads:[~2010-04-29 19:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-29 19:18 Kristen Carlson Accardi [this message]
2010-04-29 19:41 ` [PATCH] ppp: silently drop invalid packets Denis Kenzior
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=1272568709-6812-1-git-send-email-kristen@linux.intel.com \
--to=kristen@linux.intel.com \
--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