From 9164c4f309aa6b84c82d288bb25479714df73b7a Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Tue, 14 Apr 2015 22:15:11 +0200 Subject: [PATCH] PPP, MPPE, removed address, control and protocol from compressor output Our PPP stack deals with packet without address and control byte nor 2-byte protocol field, improved mppe_compress() so we don't have to worry about them. --- src/netif/ppp/mppe.c | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/src/netif/ppp/mppe.c b/src/netif/ppp/mppe.c index b90879c7..5baf2fb1 100644 --- a/src/netif/ppp/mppe.c +++ b/src/netif/ppp/mppe.c @@ -295,27 +295,17 @@ mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf, return 0; /* Make sure we have enough room to generate an encrypted packet. */ - if (osize < isize + MPPE_OVHD + 2) { + if (osize < isize + MPPE_OVHD - PPP_HDRLEN + 2) { /* Drop the packet if we should encrypt it, but can't. */ PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: osize too small! " "(have: %d need: %d)\n", state->unit, - osize, osize + MPPE_OVHD + 2)); + osize, osize + MPPE_OVHD - PPP_HDRLEN + 2)); return -1; } - osize = isize + MPPE_OVHD + 2; + osize = isize + MPPE_OVHD - PPP_HDRLEN + 2; - /* - * Copy over the PPP header and set control bits. - */ - /* FIXME: use PUT* macros */ - obuf[0] = PPP_ADDRESS(ibuf); - obuf[1] = PPP_CONTROL(ibuf); - obuf[2] = PPP_COMP>>8; - obuf[3] = PPP_COMP; - obuf += PPP_HDRLEN; - state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; if (state->debug >= 7) PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: ccount %d\n", state->unit,