PPP, MPPE, optimized struct ppp_mppe_state size

This commit is contained in:
Sylvain Rochet 2015-04-18 13:41:38 +02:00
parent b553df860c
commit f79bc03360
2 changed files with 21 additions and 20 deletions

View File

@ -137,23 +137,24 @@
*/ */
struct ppp_mppe_state { struct ppp_mppe_state {
arc4_context arc4; arc4_context arc4;
unsigned char master_key[MPPE_MAX_KEY_LEN]; u8_t master_key[MPPE_MAX_KEY_LEN];
unsigned char session_key[MPPE_MAX_KEY_LEN]; u8_t session_key[MPPE_MAX_KEY_LEN];
unsigned keylen; /* key length in bytes */ u8_t keylen; /* key length in bytes */
/* NB: 128-bit == 16, 40-bit == 8! */ /* NB: 128-bit == 16, 40-bit == 8!
/* If we want to support 56-bit, */ * If we want to support 56-bit, the unit has to change to bits
/* the unit has to change to bits */ */
unsigned char bits; /* MPPE control bits */ u8_t bits; /* MPPE control bits */
unsigned ccount; /* 12-bit coherency count (seqno) */ u16_t ccount; /* 12-bit coherency count (seqno) */
unsigned stateful; /* stateful mode flag */ unsigned int stateful :1; /* stateful mode flag */
int discard; /* stateful mode packet loss flag */ unsigned int discard :1; /* stateful mode packet loss flag */
int sanity_errors; /* take down LCP if too many */ unsigned int debug :1; /* debug flag */
int unit; unsigned int :5; /* 5 bit of padding to round out to 8 bits */
int debug; u16_t sanity_errors; /* take down LCP if too many */
u8_t unit;
}; };
int mppe_init(struct ppp_mppe_state *state, unsigned char *options, int optlen, int mppe_init(struct ppp_mppe_state *state, unsigned char *options, int optlen,
int unit, int debug, const char *debugstr); u8_t unit, u8_t debug, const char *debugstr);
void mppe_comp_reset(struct ppp_mppe_state *state); void mppe_comp_reset(struct ppp_mppe_state *state);
err_t mppe_compress(struct ppp_mppe_state *state, struct pbuf **pb, u16_t protocol); err_t mppe_compress(struct ppp_mppe_state *state, struct pbuf **pb, u16_t protocol);
void mppe_decomp_reset(struct ppp_mppe_state *state); void mppe_decomp_reset(struct ppp_mppe_state *state);

View File

@ -117,7 +117,7 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key)
* Initialize (de)compressor state. * Initialize (de)compressor state.
*/ */
int int
mppe_init(struct ppp_mppe_state *state, unsigned char *options, int optlen, int unit, int debug, mppe_init(struct ppp_mppe_state *state, unsigned char *options, int optlen, u8_t unit, u8_t debug,
const char *debugstr) const char *debugstr)
{ {
unsigned char mppe_opts; unsigned char mppe_opts;
@ -218,7 +218,7 @@ mppe_compress(struct ppp_mppe_state *state, struct pbuf **pb, u16_t protocol)
pl = (u8_t*)np->payload; pl = (u8_t*)np->payload;
state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE; state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE;
if (state->debug >= 7) if (state->debug)
PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: ccount %d\n", state->unit, PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: ccount %d\n", state->unit,
state->ccount)); state->ccount));
/* FIXME: use PUT* macros */ /* FIXME: use PUT* macros */
@ -274,9 +274,9 @@ mppe_decompress(struct ppp_mppe_state *state, struct pbuf **pb)
{ {
struct pbuf *n0 = *pb, *n; struct pbuf *n0 = *pb, *n;
u8_t *pl; u8_t *pl;
unsigned ccount; u16_t ccount;
int flushed; u8_t flushed;
int sanity = 0; u8_t sanity = 0;
/* MPPE Header */ /* MPPE Header */
if (n0->len < MPPE_OVHD) { if (n0->len < MPPE_OVHD) {
@ -290,7 +290,7 @@ mppe_decompress(struct ppp_mppe_state *state, struct pbuf **pb)
pl = (u8_t*)n0->payload; pl = (u8_t*)n0->payload;
flushed = MPPE_BITS(pl) & MPPE_BIT_FLUSHED; flushed = MPPE_BITS(pl) & MPPE_BIT_FLUSHED;
ccount = MPPE_CCOUNT(pl); ccount = MPPE_CCOUNT(pl);
if (state->debug >= 7) if (state->debug)
PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: ccount %d\n", PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: ccount %d\n",
state->unit, ccount)); state->unit, ccount));