All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fix ppp protocol-reject constructing error
@ 2011-05-11  8:15 Caiwen Zhang
  2011-05-11 18:34 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Caiwen Zhang @ 2011-05-11  8:15 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1631 bytes --]

In PPP Protocol-Reject package the 'rejected data field' should be a copy
of the rejected package, the copy starts from the data field. besides, 
Protocol-Reject package include a 'rejected protocol field', it is the
same as the protocol field of the rejected package.

Protocol-Reject package structure is:

	| PPP_header | rejected protocol | rejected data

The rejected package structure is:
	| Addr | Control | protocol | data
	
So the Protocol-Reject package data field is copied from the 3rd byte of
the rejected package.

---
 gatchat/ppp_cp.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/gatchat/ppp_cp.c b/gatchat/ppp_cp.c
index 6e4a9c5..2d47933 100644
--- a/gatchat/ppp_cp.c
+++ b/gatchat/ppp_cp.c
@@ -922,7 +922,8 @@ void pppcp_send_protocol_reject(struct pppcp_data *data,
 	 * info should contain the old packet info, plus the 16bit
 	 * protocol number we are rejecting.
 	 */
-	packet = pppcp_packet_new(data, PPPCP_CODE_TYPE_PROTOCOL_REJECT, len);
+	packet = pppcp_packet_new(data, PPPCP_CODE_TYPE_PROTOCOL_REJECT,
+		len - 2);
 
 	/*
 	 * Identifier must be changed for each Protocol-Reject sent
@@ -933,8 +934,7 @@ void pppcp_send_protocol_reject(struct pppcp_data *data,
 	 * 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));
+	memcpy(packet->data, rejected_packet + 2, len - 2);
 
 	ppp_transmit(data->ppp, pppcp_to_ppp_packet(packet),
 			ntohs(packet->length));
-- 
1.7.5

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-05-11 18:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-11  8:15 [PATCH] fix ppp protocol-reject constructing error Caiwen Zhang
2011-05-11 18:34 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.