From: Kristen Carlson Accardi <kristen@linux.intel.com>
To: ofono@ofono.org
Subject: [PATCH] ppp: implement Max-Failure counter
Date: Fri, 02 Apr 2010 22:27:00 -0700 [thread overview]
Message-ID: <1270272420-4468-1-git-send-email-kristen@linux.intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 2216 bytes --]
put a cap on the number of Configure-Nak packets we send.
---
gatchat/ppp_cp.c | 22 ++++++++++++++++++++++
gatchat/ppp_cp.h | 1 +
2 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/gatchat/ppp_cp.c b/gatchat/ppp_cp.c
index cf2f5fa..5e854da 100644
--- a/gatchat/ppp_cp.c
+++ b/gatchat/ppp_cp.c
@@ -238,6 +238,15 @@ static void copy_option(gpointer data, gpointer user_data)
*location += option->length;
}
+static void reject_option(gpointer data, gpointer user_data)
+{
+ struct ppp_option *option = data;
+ struct pppcp_data *pppcp = user_data;
+
+ pppcp->rejected_options =
+ g_list_append(pppcp->rejected_options, option);
+}
+
static void print_option(gpointer data, gpointer user_data)
{
struct ppp_option *option = data;
@@ -315,6 +324,8 @@ static void pppcp_send_configure_ack(struct pppcp_data *data,
pppcp_trace(data);
+ data->failure_counter = 0;
+
g_list_foreach(data->acceptable_options, print_option, data);
/* subtract for header. */
@@ -347,6 +358,16 @@ static void pppcp_send_configure_nak(struct pppcp_data *data,
guint8 olength;
guint8 *odata;
+ /*
+ * if we have exceeded our Max-Failure counter, we need
+ * to convert all packets to Configure-Reject
+ */
+ if (data->failure_counter >= data->max_failure) {
+ g_list_foreach(data->unacceptable_options, reject_option, data);
+ g_list_free(data->unacceptable_options);
+ data->unacceptable_options = NULL;
+ }
+
/* if we have any rejected options, send a config-reject */
if (g_list_length(data->rejected_options)) {
pppcp_trace(data);
@@ -395,6 +416,7 @@ static void pppcp_send_configure_nak(struct pppcp_data *data,
ntohs(packet->length));
pppcp_packet_free(packet);
+ data->failure_counter++;
}
}
diff --git a/gatchat/ppp_cp.h b/gatchat/ppp_cp.h
index 5b5d589..ee7ac8d 100644
--- a/gatchat/ppp_cp.h
+++ b/gatchat/ppp_cp.h
@@ -111,6 +111,7 @@ struct pppcp_data {
struct pppcp_timer_data config_timer_data;
struct pppcp_timer_data terminate_timer_data;
guint max_failure;
+ guint failure_counter;
guint32 magic_number;
GList *config_options;
GList *acceptable_options;
--
1.6.6.1
next reply other threads:[~2010-04-03 5:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-03 5:27 Kristen Carlson Accardi [this message]
2010-04-03 5:35 ` [PATCH] ppp: implement Max-Failure counter Kristen Carlson Accardi
2010-04-05 14:46 ` 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=1270272420-4468-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