mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-01-15 22:49:16 +00:00
PPP, MPPE, removed mppe_alloc() and mppe_free()
We are going to use statically allocated struct ppp_mppe_state through PPP PCB, removed now useless mppe_alloc() and mppe_free(). Merged mppe_alloc() key copy to mppe_init().
This commit is contained in:
parent
da40445d75
commit
879c94b01e
@ -152,8 +152,6 @@ struct ppp_mppe_state {
|
||||
int debug;
|
||||
};
|
||||
|
||||
struct ppp_mppe_state *mppe_alloc(unsigned char *options, int optlen);
|
||||
void mppe_free(struct ppp_mppe_state *state);
|
||||
int mppe_comp_init(struct ppp_mppe_state *state, unsigned char *options, int optlen, int unit,
|
||||
int hdrlen, int debug);
|
||||
void mppe_comp_reset(struct ppp_mppe_state *state);
|
||||
|
@ -113,49 +113,6 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key)
|
||||
arc4_setup(&state->arc4, state->session_key, state->keylen);
|
||||
}
|
||||
|
||||
/*
|
||||
* Allocate space for a (de)compressor.
|
||||
*/
|
||||
struct ppp_mppe_state *mppe_alloc(unsigned char *options, int optlen)
|
||||
{
|
||||
struct ppp_mppe_state *state;
|
||||
|
||||
if (optlen != CILEN_MPPE + sizeof(state->master_key) ||
|
||||
options[0] != CI_MPPE || options[1] != CILEN_MPPE)
|
||||
goto out;
|
||||
|
||||
/* FIXME: remove malloc() */
|
||||
state = (struct ppp_mppe_state *)malloc(sizeof(*state));
|
||||
if (state == NULL)
|
||||
goto out;
|
||||
|
||||
/* Save keys. */
|
||||
memcpy(state->master_key, &options[CILEN_MPPE],
|
||||
sizeof(state->master_key));
|
||||
memcpy(state->session_key, state->master_key,
|
||||
sizeof(state->master_key));
|
||||
|
||||
/*
|
||||
* We defer initial key generation until mppe_init(), as mppe_alloc()
|
||||
* is called frequently during negotiation.
|
||||
*/
|
||||
|
||||
return state;
|
||||
|
||||
out:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Deallocate space for a (de)compressor.
|
||||
*/
|
||||
void mppe_free(struct ppp_mppe_state *state)
|
||||
{
|
||||
if (state) {
|
||||
free(state);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Initialize (de)compressor state.
|
||||
*/
|
||||
@ -165,10 +122,14 @@ mppe_init(struct ppp_mppe_state *state, unsigned char *options, int optlen, int
|
||||
{
|
||||
unsigned char mppe_opts;
|
||||
|
||||
if (optlen != CILEN_MPPE ||
|
||||
if (optlen != CILEN_MPPE + sizeof(state->master_key) ||
|
||||
options[0] != CI_MPPE || options[1] != CILEN_MPPE)
|
||||
return 0;
|
||||
|
||||
/* Save keys. */
|
||||
MEMCPY(state->master_key, &options[CILEN_MPPE], sizeof(state->master_key));
|
||||
MEMCPY(state->session_key, state->master_key, sizeof(state->master_key));
|
||||
|
||||
MPPE_CI_TO_OPTS(&options[2], mppe_opts);
|
||||
if (mppe_opts & MPPE_OPT_128)
|
||||
state->keylen = 16;
|
||||
|
Loading…
Reference in New Issue
Block a user