summaryrefslogtreecommitdiffstats
path: root/gatchat/ppp_cp.c
diff options
context:
space:
mode:
authorKristen Carlson Accardi <kristen@linux.intel.com>2010-03-26 18:34:28 -0700
committerMarcel Holtmann <marcel@holtmann.org>2010-03-26 19:19:46 -0700
commit5260379d98e5ea334b7d5a19448bdd0d521c0c2b (patch)
treec08c9703d68d0bedb440664d7e6f3e90a9c5c02f /gatchat/ppp_cp.c
parent3772a6401cf76b858fa847c0b0ece1de31426366 (diff)
downloadofono-5260379d98e5ea334b7d5a19448bdd0d521c0c2b.tar.bz2
ppp: send Protocol-Reject
change ppp_decode to store the length of the decoded frame, so that if we have a packet with a protocol we don't understand, we can send Protocol-Reject packets. Modify ppp_cp code to add support for sending Protocol-Reject packet.
Diffstat (limited to 'gatchat/ppp_cp.c')
-rw-r--r--gatchat/ppp_cp.c42
1 files changed, 42 insertions, 0 deletions
diff --git a/gatchat/ppp_cp.c b/gatchat/ppp_cp.c
index f83cfbad..263fa8ba 100644
--- a/gatchat/ppp_cp.c
+++ b/gatchat/ppp_cp.c
@@ -1442,6 +1442,48 @@ static guint8 pppcp_process_discard_request(struct pppcp_data *data,
return 0;
}
+void pppcp_send_protocol_reject(struct pppcp_data *data,
+ guint8 *rejected_packet, gsize len)
+{
+ struct pppcp_packet *packet;
+ struct ppp_header *ppp_packet = (struct ppp_header *) rejected_packet;
+
+ pppcp_trace(data);
+
+ /*
+ * Protocol-Reject can only be sent when we are in
+ * the OPENED state. If in any other state, silently discard.
+ */
+ if (data->state != OPENED) {
+ g_free(ppp_packet);
+ return;
+ }
+
+ /*
+ * info should contain the old packet info, plus the 16bit
+ * protocol number we are rejecting.
+ */
+ packet = pppcp_packet_new(data, PROTOCOL_REJECT, len);
+
+ /*
+ * Identifier must be changed for each Protocol-Reject sent
+ */
+ packet->identifier = new_identity(data, data->reject_identifier);
+
+ /*
+ * rejected packet should be copied in, but it should be
+ * truncated if it needs to be to comply with mtu requirement
+ */
+ memcpy(packet->data, rejected_packet,
+ (ntohs(packet->length) - CP_HEADER_SZ));
+
+ ppp_transmit(data->ppp, pppcp_to_ppp_packet(packet),
+ ntohs(packet->length));
+
+ pppcp_packet_free(packet);
+
+}
+
/*
* parse the packet and determine which event this packet caused
*/