mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2025-02-06 00:39:59 +00:00
PPP, MPPE, replaced printk() to PPPDEBUG()
This commit is contained in:
parent
434fb1e0da
commit
0810384555
@ -38,6 +38,7 @@
|
|||||||
#include <asm/unaligned.h>
|
#include <asm/unaligned.h>
|
||||||
|
|
||||||
#include "netif/ppp/mppe.h"
|
#include "netif/ppp/mppe.h"
|
||||||
|
#include "netif/ppp/pppdebug.h"
|
||||||
|
|
||||||
MODULE_AUTHOR("Frank Cusack <fcusack@fcusack.com>");
|
MODULE_AUTHOR("Frank Cusack <fcusack@fcusack.com>");
|
||||||
MODULE_DESCRIPTION("Point-to-Point Protocol Microsoft Point-to-Point Encryption support");
|
MODULE_DESCRIPTION("Point-to-Point Protocol Microsoft Point-to-Point Encryption support");
|
||||||
@ -154,7 +155,7 @@ static void mppe_rekey(struct ppp_mppe_state * state, int initial_key)
|
|||||||
setup_sg(sg_out, state->session_key, state->keylen);
|
setup_sg(sg_out, state->session_key, state->keylen);
|
||||||
if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in,
|
if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in,
|
||||||
state->keylen) != 0) {
|
state->keylen) != 0) {
|
||||||
printk(KERN_WARNING "mppe_rekey: cipher_encrypt failed\n");
|
PPPDEBUG(LOG_DEBUG, ("mppe_rekey: cipher_encrypt failed\n"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
memcpy(state->session_key, state->sha1_digest, state->keylen);
|
memcpy(state->session_key, state->sha1_digest, state->keylen);
|
||||||
@ -267,8 +268,8 @@ mppe_init(void *arg, unsigned char *options, int optlen, int unit, int debug,
|
|||||||
else if (mppe_opts & MPPE_OPT_40)
|
else if (mppe_opts & MPPE_OPT_40)
|
||||||
state->keylen = 8;
|
state->keylen = 8;
|
||||||
else {
|
else {
|
||||||
printk(KERN_WARNING "%s[%d]: unknown key length\n", debugstr,
|
PPPDEBUG(LOG_DEBUG, ("%s[%d]: unknown key length\n", debugstr,
|
||||||
unit);
|
unit));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (mppe_opts & MPPE_OPT_STATEFUL)
|
if (mppe_opts & MPPE_OPT_STATEFUL)
|
||||||
@ -282,17 +283,17 @@ mppe_init(void *arg, unsigned char *options, int optlen, int unit, int debug,
|
|||||||
char mkey[sizeof(state->master_key) * 2 + 1];
|
char mkey[sizeof(state->master_key) * 2 + 1];
|
||||||
char skey[sizeof(state->session_key) * 2 + 1];
|
char skey[sizeof(state->session_key) * 2 + 1];
|
||||||
|
|
||||||
printk(KERN_DEBUG "%s[%d]: initialized with %d-bit %s mode\n",
|
PPPDEBUG(LOG_DEBUG, ("%s[%d]: initialized with %d-bit %s mode\n",
|
||||||
debugstr, unit, (state->keylen == 16) ? 128 : 40,
|
debugstr, unit, (state->keylen == 16) ? 128 : 40,
|
||||||
(state->stateful) ? "stateful" : "stateless");
|
(state->stateful) ? "stateful" : "stateless"));
|
||||||
|
|
||||||
for (i = 0; i < sizeof(state->master_key); i++)
|
for (i = 0; i < sizeof(state->master_key); i++)
|
||||||
sprintf(mkey + i * 2, "%02x", state->master_key[i]);
|
sprintf(mkey + i * 2, "%02x", state->master_key[i]);
|
||||||
for (i = 0; i < sizeof(state->session_key); i++)
|
for (i = 0; i < sizeof(state->session_key); i++)
|
||||||
sprintf(skey + i * 2, "%02x", state->session_key[i]);
|
sprintf(skey + i * 2, "%02x", state->session_key[i]);
|
||||||
printk(KERN_DEBUG
|
PPPDEBUG(LOG_DEBUG,
|
||||||
"%s[%d]: keys: master: %s initial session: %s\n",
|
("%s[%d]: keys: master: %s initial session: %s\n",
|
||||||
debugstr, unit, mkey, skey);
|
debugstr, unit, mkey, skey));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -363,9 +364,9 @@ mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf,
|
|||||||
/* Make sure we have enough room to generate an encrypted packet. */
|
/* Make sure we have enough room to generate an encrypted packet. */
|
||||||
if (osize < isize + MPPE_OVHD + 2) {
|
if (osize < isize + MPPE_OVHD + 2) {
|
||||||
/* Drop the packet if we should encrypt it, but can't. */
|
/* Drop the packet if we should encrypt it, but can't. */
|
||||||
printk(KERN_DEBUG "mppe_compress[%d]: osize too small! "
|
PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: osize too small! "
|
||||||
"(have: %d need: %d)\n", state->unit,
|
"(have: %d need: %d)\n", state->unit,
|
||||||
osize, osize + MPPE_OVHD + 2);
|
osize, osize + MPPE_OVHD + 2));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,8 +382,8 @@ mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf,
|
|||||||
|
|
||||||
state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE;
|
state->ccount = (state->ccount + 1) % MPPE_CCOUNT_SPACE;
|
||||||
if (state->debug >= 7)
|
if (state->debug >= 7)
|
||||||
printk(KERN_DEBUG "mppe_compress[%d]: ccount %d\n", state->unit,
|
PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: ccount %d\n", state->unit,
|
||||||
state->ccount);
|
state->ccount));
|
||||||
put_unaligned_be16(state->ccount, obuf);
|
put_unaligned_be16(state->ccount, obuf);
|
||||||
|
|
||||||
if (!state->stateful || /* stateless mode */
|
if (!state->stateful || /* stateless mode */
|
||||||
@ -390,8 +391,8 @@ mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf,
|
|||||||
(state->bits & MPPE_BIT_FLUSHED)) { /* CCP Reset-Request */
|
(state->bits & MPPE_BIT_FLUSHED)) { /* CCP Reset-Request */
|
||||||
/* We must rekey */
|
/* We must rekey */
|
||||||
if (state->debug && state->stateful)
|
if (state->debug && state->stateful)
|
||||||
printk(KERN_DEBUG "mppe_compress[%d]: rekeying\n",
|
PPPDEBUG(LOG_DEBUG, ("mppe_compress[%d]: rekeying\n",
|
||||||
state->unit);
|
state->unit));
|
||||||
mppe_rekey(state, 0);
|
mppe_rekey(state, 0);
|
||||||
state->bits |= MPPE_BIT_FLUSHED;
|
state->bits |= MPPE_BIT_FLUSHED;
|
||||||
}
|
}
|
||||||
@ -408,7 +409,7 @@ mppe_compress(void *arg, unsigned char *ibuf, unsigned char *obuf,
|
|||||||
setup_sg(sg_in, ibuf, isize);
|
setup_sg(sg_in, ibuf, isize);
|
||||||
setup_sg(sg_out, obuf, osize);
|
setup_sg(sg_out, obuf, osize);
|
||||||
if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, isize) != 0) {
|
if (crypto_blkcipher_encrypt(&desc, sg_out, sg_in, isize) != 0) {
|
||||||
printk(KERN_DEBUG "crypto_cypher_encrypt failed\n");
|
PPPDEBUG(LOG_DEBUG, ("crypto_cypher_encrypt failed\n"));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -464,9 +465,9 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf,
|
|||||||
|
|
||||||
if (isize <= PPP_HDRLEN + MPPE_OVHD) {
|
if (isize <= PPP_HDRLEN + MPPE_OVHD) {
|
||||||
if (state->debug)
|
if (state->debug)
|
||||||
printk(KERN_DEBUG
|
PPPDEBUG(LOG_DEBUG,
|
||||||
"mppe_decompress[%d]: short pkt (%d)\n",
|
("mppe_decompress[%d]: short pkt (%d)\n",
|
||||||
state->unit, isize);
|
state->unit, isize));
|
||||||
return DECOMP_ERROR;
|
return DECOMP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -477,35 +478,35 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf,
|
|||||||
* this is to account for possible PFC.
|
* this is to account for possible PFC.
|
||||||
*/
|
*/
|
||||||
if (osize < isize - MPPE_OVHD - 1) {
|
if (osize < isize - MPPE_OVHD - 1) {
|
||||||
printk(KERN_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 DECOMP_ERROR;
|
return DECOMP_ERROR;
|
||||||
}
|
}
|
||||||
osize = isize - MPPE_OVHD - 2; /* assume no PFC */
|
osize = isize - MPPE_OVHD - 2; /* assume no PFC */
|
||||||
|
|
||||||
ccount = MPPE_CCOUNT(ibuf);
|
ccount = MPPE_CCOUNT(ibuf);
|
||||||
if (state->debug >= 7)
|
if (state->debug >= 7)
|
||||||
printk(KERN_DEBUG "mppe_decompress[%d]: ccount %d\n",
|
PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: ccount %d\n",
|
||||||
state->unit, ccount);
|
state->unit, ccount));
|
||||||
|
|
||||||
/* sanity checks -- terminate with extreme prejudice */
|
/* sanity checks -- terminate with extreme prejudice */
|
||||||
if (!(MPPE_BITS(ibuf) & MPPE_BIT_ENCRYPTED)) {
|
if (!(MPPE_BITS(ibuf) & MPPE_BIT_ENCRYPTED)) {
|
||||||
printk(KERN_DEBUG
|
PPPDEBUG(LOG_DEBUG,
|
||||||
"mppe_decompress[%d]: ENCRYPTED bit not set!\n",
|
("mppe_decompress[%d]: ENCRYPTED bit not set!\n",
|
||||||
state->unit);
|
state->unit));
|
||||||
state->sanity_errors += 100;
|
state->sanity_errors += 100;
|
||||||
sanity = 1;
|
sanity = 1;
|
||||||
}
|
}
|
||||||
if (!state->stateful && !flushed) {
|
if (!state->stateful && !flushed) {
|
||||||
printk(KERN_DEBUG "mppe_decompress[%d]: FLUSHED bit not set in "
|
PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set in "
|
||||||
"stateless mode!\n", state->unit);
|
"stateless mode!\n", state->unit));
|
||||||
state->sanity_errors += 100;
|
state->sanity_errors += 100;
|
||||||
sanity = 1;
|
sanity = 1;
|
||||||
}
|
}
|
||||||
if (state->stateful && ((ccount & 0xff) == 0xff) && !flushed) {
|
if (state->stateful && ((ccount & 0xff) == 0xff) && !flushed) {
|
||||||
printk(KERN_DEBUG "mppe_decompress[%d]: FLUSHED bit not set on "
|
PPPDEBUG(LOG_DEBUG, ("mppe_decompress[%d]: FLUSHED bit not set on "
|
||||||
"flag packet!\n", state->unit);
|
"flag packet!\n", state->unit));
|
||||||
state->sanity_errors += 100;
|
state->sanity_errors += 100;
|
||||||
sanity = 1;
|
sanity = 1;
|
||||||
}
|
}
|
||||||
@ -597,7 +598,7 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf,
|
|||||||
setup_sg(sg_in, ibuf, 1);
|
setup_sg(sg_in, ibuf, 1);
|
||||||
setup_sg(sg_out, obuf, 1);
|
setup_sg(sg_out, obuf, 1);
|
||||||
if (crypto_blkcipher_decrypt(&desc, sg_out, sg_in, 1) != 0) {
|
if (crypto_blkcipher_decrypt(&desc, sg_out, sg_in, 1) != 0) {
|
||||||
printk(KERN_DEBUG "crypto_cypher_decrypt failed\n");
|
PPPDEBUG(LOG_DEBUG, ("crypto_cypher_decrypt failed\n"));
|
||||||
return DECOMP_ERROR;
|
return DECOMP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -617,7 +618,7 @@ mppe_decompress(void *arg, unsigned char *ibuf, int isize, unsigned char *obuf,
|
|||||||
setup_sg(sg_in, ibuf + 1, isize - 1);
|
setup_sg(sg_in, ibuf + 1, isize - 1);
|
||||||
setup_sg(sg_out, obuf + 1, osize - 1);
|
setup_sg(sg_out, obuf + 1, osize - 1);
|
||||||
if (crypto_blkcipher_decrypt(&desc, sg_out, sg_in, isize - 1)) {
|
if (crypto_blkcipher_decrypt(&desc, sg_out, sg_in, isize - 1)) {
|
||||||
printk(KERN_DEBUG "crypto_cypher_decrypt failed\n");
|
PPPDEBUG(LOG_DEBUG, ("crypto_cypher_decrypt failed\n"));
|
||||||
return DECOMP_ERROR;
|
return DECOMP_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -644,9 +645,9 @@ static void mppe_incomp(void *arg, unsigned char *ibuf, int icnt)
|
|||||||
|
|
||||||
if (state->debug &&
|
if (state->debug &&
|
||||||
(PPP_PROTOCOL(ibuf) >= 0x0021 && PPP_PROTOCOL(ibuf) <= 0x00fa))
|
(PPP_PROTOCOL(ibuf) >= 0x0021 && PPP_PROTOCOL(ibuf) <= 0x00fa))
|
||||||
printk(KERN_DEBUG
|
PPPDEBUG(LOG_DEBUG,
|
||||||
"mppe_incomp[%d]: incompressible (unencrypted) data! "
|
("mppe_incomp[%d]: incompressible (unencrypted) data! "
|
||||||
"(proto %04x)\n", state->unit, PPP_PROTOCOL(ibuf));
|
"(proto %04x)\n", state->unit, PPP_PROTOCOL(ibuf)));
|
||||||
|
|
||||||
state->stats.inc_bytes += icnt;
|
state->stats.inc_bytes += icnt;
|
||||||
state->stats.inc_packets++;
|
state->stats.inc_packets++;
|
||||||
@ -703,7 +704,7 @@ static int __init ppp_mppe_init(void)
|
|||||||
answer = ppp_register_compressor(&ppp_mppe);
|
answer = ppp_register_compressor(&ppp_mppe);
|
||||||
|
|
||||||
if (answer == 0)
|
if (answer == 0)
|
||||||
printk(KERN_INFO "PPP MPPE Compression module registered\n");
|
PPPDEBUG(LOG_DEBUG, ("PPP MPPE Compression module registered\n"));
|
||||||
else
|
else
|
||||||
kfree(sha_pad);
|
kfree(sha_pad);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user