mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-29 00:32:51 +00:00
PPP, MPPE, handle packets in decompressor without address and control nor protocol
Our PPP stack deals with packet without address and control byte nor 2-byte protocol field, improved mppe_decompress() so we don't have to worry about them.
This commit is contained in:
parent
0e1aec4348
commit
5f0e261f2d
@ -80,8 +80,8 @@ struct ppp_mppe_state {
|
|||||||
#define MPPE_BIT_FLUSHED MPPE_BIT_A
|
#define MPPE_BIT_FLUSHED MPPE_BIT_A
|
||||||
#define MPPE_BIT_ENCRYPTED MPPE_BIT_D
|
#define MPPE_BIT_ENCRYPTED MPPE_BIT_D
|
||||||
|
|
||||||
#define MPPE_BITS(p) ((p)[4] & 0xf0)
|
#define MPPE_BITS(p) ((p)[0] & 0xf0)
|
||||||
#define MPPE_CCOUNT(p) ((((p)[4] & 0x0f) << 8) + (p)[5])
|
#define MPPE_CCOUNT(p) ((((p)[0] & 0x0f) << 8) + (p)[1])
|
||||||
#define MPPE_CCOUNT_SPACE 0x1000 /* The size of the ccount space */
|
#define MPPE_CCOUNT_SPACE 0x1000 /* The size of the ccount space */
|
||||||
|
|
||||||
#define MPPE_OVHD 2 /* MPPE overhead/packet */
|
#define MPPE_OVHD 2 /* MPPE overhead/packet */
|
||||||
@ -377,7 +377,7 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf,
|
|||||||
int flushed = MPPE_BITS(ibuf) & MPPE_BIT_FLUSHED;
|
int flushed = MPPE_BITS(ibuf) & MPPE_BIT_FLUSHED;
|
||||||
int sanity = 0;
|
int sanity = 0;
|
||||||
|
|
||||||
if (isize <= PPP_HDRLEN + MPPE_OVHD) {
|
if (isize <= MPPE_OVHD) {
|
||||||
if (state->debug)
|
if (state->debug)
|
||||||
PPPDEBUG(LOG_DEBUG,
|
PPPDEBUG(LOG_DEBUG,
|
||||||
("mppe_decompress[%d]: short pkt (%d)\n",
|
("mppe_decompress[%d]: short pkt (%d)\n",
|
||||||
@ -387,17 +387,15 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf,
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Make sure we have enough room to decrypt the packet.
|
* Make sure we have enough room to decrypt the packet.
|
||||||
* Note that for our test we only subtract 1 byte whereas in
|
* Note that for our test we add 1 byte to account for possible PFC.
|
||||||
* mppe_compress() we added 2 bytes (+MPPE_OVHD);
|
|
||||||
* this is to account for possible PFC.
|
|
||||||
*/
|
*/
|
||||||
if (osize < isize - MPPE_OVHD - 1) {
|
if (osize < isize - MPPE_OVHD + 1) {
|
||||||
PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: osize too small! "
|
PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: osize too small! "
|
||||||
"(have: %d need: %d)\n", state->unit,
|
"(have: %d need: %d)\n", state->unit,
|
||||||
osize, isize - MPPE_OVHD - 1));
|
osize, isize - MPPE_OVHD + 1));
|
||||||
return ERR_BUF;
|
return ERR_BUF;
|
||||||
}
|
}
|
||||||
osize = isize - MPPE_OVHD - 2; /* assume no PFC */
|
osize = isize - MPPE_OVHD; /* assume no PFC */
|
||||||
|
|
||||||
ccount = MPPE_CCOUNT(ibuf);
|
ccount = MPPE_CCOUNT(ibuf);
|
||||||
if (state->debug >= 7)
|
if (state->debug >= 7)
|
||||||
@ -497,12 +495,8 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf,
|
|||||||
* Fill in the first part of the PPP header. The protocol field
|
* Fill in the first part of the PPP header. The protocol field
|
||||||
* comes from the decrypted data.
|
* comes from the decrypted data.
|
||||||
*/
|
*/
|
||||||
obuf[0] = PPP_ADDRESS(ibuf); /* +1 */
|
ibuf += MPPE_OVHD;
|
||||||
obuf[1] = PPP_CONTROL(ibuf); /* +1 */
|
isize -= MPPE_OVHD;
|
||||||
obuf += 2;
|
|
||||||
ibuf += PPP_HDRLEN + MPPE_OVHD;
|
|
||||||
isize -= PPP_HDRLEN + MPPE_OVHD; /* -6 */
|
|
||||||
/* net osize: isize-4 */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Decrypt the first byte in order to check if it is
|
* Decrypt the first byte in order to check if it is
|
||||||
|
Loading…
x
Reference in New Issue
Block a user