summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristen Carlson Accardi <kristen@linux.intel.com>2010-04-26 11:44:36 -0700
committerDenis Kenzior <denkenz@gmail.com>2010-04-26 15:31:17 -0500
commita9c0be7339f3df75d1aaa5feb2330bd6a414582f (patch)
tree1ef0250e102a0abc9162af412d6496fff554080f
parentfce78feb549ccaad55cf3943391b2cad9a4b6646 (diff)
downloadofono-a9c0be7339f3df75d1aaa5feb2330bd6a414582f.tar.bz2
ppp: use default ACCM when sending LCP codes 1-7
According to the spec, you must transmit all Link Configuration, Termination, and Code-Reject packets as if no options had been negotiated. This requires that when encoding we use the default ACCM of 0xffffffff when sending these types of packets.
-rw-r--r--gatchat/gatppp.c10
-rw-r--r--gatchat/ppp_cp.c8
-rw-r--r--gatchat/ppp_cp.h2
3 files changed, 20 insertions, 0 deletions
diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index 1547a753..c7bf089b 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -124,6 +124,7 @@ static struct frame_buffer *ppp_encode(GAtPPP *ppp, guint8 *data, int len)
int i = 0;
guint16 fcs = PPPINITFCS16;
guint16 proto = get_host_short(data);
+ guint8 code;
gboolean lcp = (proto == LCP_PROTOCOL);
guint8 *frame;
struct frame_buffer *fb =
@@ -133,6 +134,15 @@ static struct frame_buffer *ppp_encode(GAtPPP *ppp, guint8 *data, int len)
return NULL;
frame = fb->bytes;
+ /*
+ * all LCP Link Configuration, Link Termination, and Code-Reject
+ * packets must be sent with the default sending ACCM
+ */
+ if (lcp) {
+ code = pppcp_get_code(data);
+ lcp = code > 0 && code < 8;
+ }
+
/* copy in the HDLC framing */
frame[pos++] = PPP_FLAG_SEQ;
diff --git a/gatchat/ppp_cp.c b/gatchat/ppp_cp.c
index 6cd36817..dfb4dbe6 100644
--- a/gatchat/ppp_cp.c
+++ b/gatchat/ppp_cp.c
@@ -267,6 +267,14 @@ const guint8 *ppp_option_iter_get_data(struct ppp_option_iter *iter)
return iter->option_data;
}
+guint8 pppcp_get_code(const guint8 *data)
+{
+ struct ppp_header *ppp_packet = (struct ppp_header *) data;
+ struct pppcp_packet *packet = (struct pppcp_packet *) ppp_packet->info;
+
+ return packet->code;
+}
+
static gboolean pppcp_timeout(gpointer user_data)
{
struct pppcp_timer_data *timer_data = user_data;
diff --git a/gatchat/ppp_cp.h b/gatchat/ppp_cp.h
index 519a4a0a..8930e505 100644
--- a/gatchat/ppp_cp.h
+++ b/gatchat/ppp_cp.h
@@ -110,6 +110,8 @@ void pppcp_set_data(struct pppcp_data *pppcp, gpointer data);
gpointer pppcp_get_data(struct pppcp_data *pppcp);
GAtPPP *pppcp_get_ppp(struct pppcp_data *pppcp);
+guint8 pppcp_get_code(const guint8 *data);
+
void pppcp_set_local_options(struct pppcp_data *data,
const guint8 *options,
guint16 len);