PPP, fixed some compiler warnings

Using -Wall -pedantic -Wparentheses -Wsequence-point
-Wswitch-default -Wextra -Wundef -Wshadow -Wpointer-arith
-Wbad-function-cast -Wc++-compat -Wwrite-strings -Wold-style-definition
-Wmissing-prototypes -Wredundant-decls -Wnested-externs -Wno-address
This commit is contained in:
Sylvain Rochet 2014-12-24 15:16:03 +01:00
parent 01391f0234
commit 2b3e020152
22 changed files with 272 additions and 177 deletions

View File

@ -1927,6 +1927,13 @@
#define ECP_SUPPORT 0 #define ECP_SUPPORT 0
#endif #endif
/**
* DEMAND_SUPPORT==1: Support dial on demand. CURRENTLY NOT SUPPORTED! DO NOT SET!
*/
#ifndef DEMAND_SUPPORT
#define DEMAND_SUPPORT 0
#endif
/** /**
* LQR_SUPPORT==1: Support Link Quality Report. Do nothing except exchanging some LCP packets. * LQR_SUPPORT==1: Support Link Quality Report. Do nothing except exchanging some LCP packets.
*/ */

View File

@ -74,7 +74,7 @@
typedef struct fsm { typedef struct fsm {
ppp_pcb *pcb; /* PPP Interface */ ppp_pcb *pcb; /* PPP Interface */
const struct fsm_callbacks *callbacks; /* Callback routines */ const struct fsm_callbacks *callbacks; /* Callback routines */
char *term_reason; /* Reason for closing protocol */ const char *term_reason; /* Reason for closing protocol */
u8_t seen_ack; /* Have received valid Ack/Nak/Rej to Req */ u8_t seen_ack; /* Have received valid Ack/Nak/Rej to Req */
/* -- This is our only flag, we might use u_int :1 if we have more flags */ /* -- This is our only flag, we might use u_int :1 if we have more flags */
u16_t protocol; /* Data Link Layer Protocol field value */ u16_t protocol; /* Data Link Layer Protocol field value */
@ -120,7 +120,7 @@ typedef struct fsm_callbacks {
(fsm *); (fsm *);
int (*extcode) /* Called when unknown code received */ int (*extcode) /* Called when unknown code received */
(fsm *, int, int, u_char *, int); (fsm *, int, int, u_char *, int);
char *proto_name; /* String name for protocol (for messages) */ const char *proto_name; /* String name for protocol (for messages) */
} fsm_callbacks; } fsm_callbacks;
@ -165,7 +165,7 @@ void fsm_init(fsm *f);
void fsm_lowerup(fsm *f); void fsm_lowerup(fsm *f);
void fsm_lowerdown(fsm *f); void fsm_lowerdown(fsm *f);
void fsm_open(fsm *f); void fsm_open(fsm *f);
void fsm_close(fsm *f, char *reason); void fsm_close(fsm *f, const char *reason);
void fsm_input(fsm *f, u_char *inpacket, int l); void fsm_input(fsm *f, u_char *inpacket, int l);
void fsm_protreject(fsm *f); void fsm_protreject(fsm *f);
void fsm_sdata(fsm *f, u_char code, u_char id, u_char *data, int datalen); void fsm_sdata(fsm *f, u_char code, u_char id, u_char *data, int datalen);

View File

@ -159,7 +159,7 @@ typedef struct lcp_options {
} lcp_options; } lcp_options;
void lcp_open(ppp_pcb *pcb); void lcp_open(ppp_pcb *pcb);
void lcp_close(ppp_pcb *pcb, char *reason); void lcp_close(ppp_pcb *pcb, const char *reason);
void lcp_lowerup(ppp_pcb *pcb); void lcp_lowerup(ppp_pcb *pcb);
void lcp_lowerdown(ppp_pcb *pcb); void lcp_lowerdown(ppp_pcb *pcb);
void lcp_sprotrej(ppp_pcb *pcb, u_char *p, int len); /* send protocol reject */ void lcp_sprotrej(ppp_pcb *pcb, u_char *p, int len); /* send protocol reject */

View File

@ -53,6 +53,10 @@
#define PPP_OPTIONS 0 #define PPP_OPTIONS 0
#endif #endif
#ifndef PPP_NOTIFY
#define PPP_NOTIFY 0
#endif
#ifndef PPP_REMOTENAME #ifndef PPP_REMOTENAME
#define PPP_REMOTENAME 0 #define PPP_REMOTENAME 0
#endif #endif
@ -69,10 +73,6 @@
#define PPP_MAXCONNECT 0 #define PPP_MAXCONNECT 0
#endif #endif
#ifndef DEMAND_SUPPORT
#define DEMAND_SUPPORT 0
#endif
#ifndef PPP_ALLOWED_ADDRS #ifndef PPP_ALLOWED_ADDRS
#define PPP_ALLOWED_ADDRS 0 #define PPP_ALLOWED_ADDRS 0
#endif #endif

View File

@ -277,11 +277,11 @@ struct protent {
/* Open the protocol */ /* Open the protocol */
void (*open) (ppp_pcb *pcb); void (*open) (ppp_pcb *pcb);
/* Close the protocol */ /* Close the protocol */
void (*close) (ppp_pcb *pcb, char *reason); void (*close) (ppp_pcb *pcb, const char *reason);
#if PRINTPKT_SUPPORT #if PRINTPKT_SUPPORT
/* Print a packet in readable form */ /* Print a packet in readable form */
int (*printpkt) (u_char *pkt, int len, int (*printpkt) (u_char *pkt, int len,
void (*printer) (void *, char *, ...), void (*printer) (void *, const char *, ...),
void *arg); void *arg);
#endif /* PRINTPKT_SUPPORT */ #endif /* PRINTPKT_SUPPORT */
/* FIXME: data input is only used by CCP, which is not supported at this time, /* FIXME: data input is only used by CCP, which is not supported at this time,
@ -291,8 +291,8 @@ struct protent {
void (*datainput) (ppp_pcb *pcb, u_char *pkt, int len); void (*datainput) (ppp_pcb *pcb, u_char *pkt, int len);
u8_t enabled_flag; /* 0 if protocol is disabled */ u8_t enabled_flag; /* 0 if protocol is disabled */
#if PRINTPKT_SUPPORT #if PRINTPKT_SUPPORT
char *name; /* Text name of protocol */ const char *name; /* Text name of protocol */
char *data_name; /* Text name of corresponding data protocol */ const char *data_name; /* Text name of corresponding data protocol */
#endif /* PRINTPKT_SUPPORT */ #endif /* PRINTPKT_SUPPORT */
#if PPP_OPTIONS #if PPP_OPTIONS
option_t *options; /* List of command-line options */ option_t *options; /* List of command-line options */
@ -552,17 +552,17 @@ int str_to_epdisc (struct epdisc *, char *); /* endpt disc. from str */
#endif #endif
/* Procedures exported from utils.c. */ /* Procedures exported from utils.c. */
void ppp_print_string(char *p, int len, void (*printer) (void *, char *, ...), void *arg); /* Format a string for output */ void ppp_print_string(char *p, int len, void (*printer) (void *, const char *, ...), void *arg); /* Format a string for output */
int ppp_slprintf(char *buf, int buflen, char *fmt, ...); /* sprintf++ */ int ppp_slprintf(char *buf, int buflen, const char *fmt, ...); /* sprintf++ */
int ppp_vslprintf(char *buf, int buflen, char *fmt, va_list args); /* vsprintf++ */ int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args); /* vsprintf++ */
size_t ppp_strlcpy(char *dest, const char *src, size_t len); /* safe strcpy */ size_t ppp_strlcpy(char *dest, const char *src, size_t len); /* safe strcpy */
size_t ppp_strlcat(char *dest, const char *src, size_t len); /* safe strncpy */ size_t ppp_strlcat(char *dest, const char *src, size_t len); /* safe strncpy */
void ppp_dbglog(char *fmt, ...); /* log a debug message */ void ppp_dbglog(const char *fmt, ...); /* log a debug message */
void ppp_info(char *fmt, ...); /* log an informational message */ void ppp_info(const char *fmt, ...); /* log an informational message */
void ppp_notice(char *fmt, ...); /* log a notice-level message */ void ppp_notice(const char *fmt, ...); /* log a notice-level message */
void ppp_warn(char *fmt, ...); /* log a warning message */ void ppp_warn(const char *fmt, ...); /* log a warning message */
void ppp_error(char *fmt, ...); /* log an error message */ void ppp_error(const char *fmt, ...); /* log an error message */
void ppp_fatal(char *fmt, ...); /* log an error message and die(1) */ void ppp_fatal(const char *fmt, ...); /* log an error message and die(1) */
#if PRINTPKT_SUPPORT #if PRINTPKT_SUPPORT
void ppp_dump_packet(const char *tag, unsigned char *p, int len); void ppp_dump_packet(const char *tag, unsigned char *p, int len);
/* dump packet to debug log if interesting */ /* dump packet to debug log if interesting */

View File

@ -1037,6 +1037,8 @@ void auth_peer_success(ppp_pcb *pcb, int protocol, int prot_flavor, char *name,
bit |= CHAP_MS2_PEER; bit |= CHAP_MS2_PEER;
break; break;
#endif /* MSCHAP_SUPPORT */ #endif /* MSCHAP_SUPPORT */
default:
break;
} }
break; break;
#endif /* CHAP_SUPPORT */ #endif /* CHAP_SUPPORT */
@ -1123,6 +1125,8 @@ void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor) {
bit |= CHAP_MS2_WITHPEER; bit |= CHAP_MS2_WITHPEER;
break; break;
#endif /* MSCHAP_SUPPORT */ #endif /* MSCHAP_SUPPORT */
default:
break;
} }
break; break;
#endif /* CHAP_SUPPORT */ #endif /* CHAP_SUPPORT */

View File

@ -168,7 +168,7 @@ static option_t ccp_option_list[] = {
*/ */
static void ccp_init (int unit); static void ccp_init (int unit);
static void ccp_open (int unit); static void ccp_open (int unit);
static void ccp_close (int unit, char *); static void ccp_close (int unit, const char *);
static void ccp_lowerup (int unit); static void ccp_lowerup (int unit);
static void ccp_lowerdown (int); static void ccp_lowerdown (int);
static void ccp_input (int unit, u_char *pkt, int len); static void ccp_input (int unit, u_char *pkt, int len);
@ -421,7 +421,7 @@ ccp_open(unit)
static void static void
ccp_close(unit, reason) ccp_close(unit, reason)
int unit; int unit;
char *reason; const char *reason;
{ {
ccp_flags_set(unit, 0, 0); ccp_flags_set(unit, 0, 0);
fsm_close(&ccp_fsm[unit], reason); fsm_close(&ccp_fsm[unit], reason);

View File

@ -95,12 +95,12 @@ static int chap_md5_verify_response(int id, char *name,
static void chap_md5_make_response(unsigned char *response, int id, char *our_name, static void chap_md5_make_response(unsigned char *response, int id, char *our_name,
unsigned char *challenge, char *secret, int secret_len, unsigned char *challenge, char *secret, int secret_len,
unsigned char *private) { unsigned char *private_) {
md5_context ctx; md5_context ctx;
unsigned char idbyte = id; unsigned char idbyte = id;
int challenge_len = *challenge++; int challenge_len = *challenge++;
LWIP_UNUSED_ARG(our_name); LWIP_UNUSED_ARG(our_name);
LWIP_UNUSED_ARG(private); LWIP_UNUSED_ARG(private_);
md5_starts(&ctx); md5_starts(&ctx);
md5_update(&ctx, &idbyte, 1); md5_update(&ctx, &idbyte, 1);

View File

@ -102,7 +102,7 @@ static void chap_protrej(ppp_pcb *pcb);
static void chap_input(ppp_pcb *pcb, unsigned char *pkt, int pktlen); static void chap_input(ppp_pcb *pcb, unsigned char *pkt, int pktlen);
#if PRINTPKT_SUPPORT #if PRINTPKT_SUPPORT
static int chap_print_pkt(unsigned char *p, int plen, static int chap_print_pkt(unsigned char *p, int plen,
void (*printer) (void *, char *, ...), void *arg); void (*printer) (void *, const char *, ...), void *arg);
#endif /* PRINTPKT_SUPPORT */ #endif /* PRINTPKT_SUPPORT */
/* List of digest types that we know about */ /* List of digest types that we know about */
@ -339,7 +339,7 @@ static void chap_handle_response(ppp_pcb *pcb, int id,
return; return;
} }
outp = p->payload; outp = (unsigned char *)p->payload;
MAKEHEADER(outp, PPP_CHAP); MAKEHEADER(outp, PPP_CHAP);
outp[0] = (pcb->chap_server.flags & AUTH_FAILED)? CHAP_FAILURE: CHAP_SUCCESS; outp[0] = (pcb->chap_server.flags & AUTH_FAILED)? CHAP_FAILURE: CHAP_SUCCESS;
@ -464,7 +464,7 @@ static void chap_respond(ppp_pcb *pcb, int id,
ppp_warn("No CHAP secret found for authenticating us to %q", rname); ppp_warn("No CHAP secret found for authenticating us to %q", rname);
} }
outp = p->payload; outp = (u_char*)p->payload;
MAKEHEADER(outp, PPP_CHAP); MAKEHEADER(outp, PPP_CHAP);
outp += CHAP_HDRLEN; outp += CHAP_HDRLEN;
@ -551,6 +551,8 @@ static void chap_input(ppp_pcb *pcb, unsigned char *pkt, int pktlen) {
case CHAP_SUCCESS: case CHAP_SUCCESS:
chap_handle_status(pcb, code, id, pkt, len); chap_handle_status(pcb, code, id, pkt, len);
break; break;
default:
break;
} }
} }
@ -577,12 +579,12 @@ static void chap_protrej(ppp_pcb *pcb) {
/* /*
* chap_print_pkt - print the contents of a CHAP packet. * chap_print_pkt - print the contents of a CHAP packet.
*/ */
static char *chap_code_names[] = { static const char *chap_code_names[] = {
"Challenge", "Response", "Success", "Failure" "Challenge", "Response", "Success", "Failure"
}; };
static int chap_print_pkt(unsigned char *p, int plen, static int chap_print_pkt(unsigned char *p, int plen,
void (*printer) (void *, char *, ...), void *arg) { void (*printer) (void *, const char *, ...), void *arg) {
int code, id, len; int code, id, len;
int clen, nlen; int clen, nlen;
unsigned char x; unsigned char x;

View File

@ -328,10 +328,10 @@ static int chapms2_verify_response(int id, char *name,
static void chapms_make_response(unsigned char *response, int id, char *our_name, static void chapms_make_response(unsigned char *response, int id, char *our_name,
unsigned char *challenge, char *secret, int secret_len, unsigned char *challenge, char *secret, int secret_len,
unsigned char *private) { unsigned char *private_) {
LWIP_UNUSED_ARG(id); LWIP_UNUSED_ARG(id);
LWIP_UNUSED_ARG(our_name); LWIP_UNUSED_ARG(our_name);
LWIP_UNUSED_ARG(private); LWIP_UNUSED_ARG(private_);
challenge++; /* skip length, should be 8 */ challenge++; /* skip length, should be 8 */
*response++ = MS_CHAP_RESPONSE_LEN; *response++ = MS_CHAP_RESPONSE_LEN;
ChapMS(challenge, secret, secret_len, response); ChapMS(challenge, secret, secret_len, response);
@ -339,7 +339,7 @@ static void chapms_make_response(unsigned char *response, int id, char *our_name
static void chapms2_make_response(unsigned char *response, int id, char *our_name, static void chapms2_make_response(unsigned char *response, int id, char *our_name,
unsigned char *challenge, char *secret, int secret_len, unsigned char *challenge, char *secret, int secret_len,
unsigned char *private) { unsigned char *private_) {
LWIP_UNUSED_ARG(id); LWIP_UNUSED_ARG(id);
challenge++; /* skip length, should be 16 */ challenge++; /* skip length, should be 16 */
*response++ = MS_CHAP2_RESPONSE_LEN; *response++ = MS_CHAP2_RESPONSE_LEN;
@ -349,11 +349,11 @@ static void chapms2_make_response(unsigned char *response, int id, char *our_nam
#else #else
NULL, NULL,
#endif #endif
our_name, secret, secret_len, response, private, our_name, secret, secret_len, response, private_,
MS_CHAP2_AUTHENTICATEE); MS_CHAP2_AUTHENTICATEE);
} }
static int chapms2_check_success(unsigned char *msg, int len, unsigned char *private) { static int chapms2_check_success(unsigned char *msg, int len, unsigned char *private_) {
if ((len < MS_AUTH_RESPONSE_LENGTH + 2) || if ((len < MS_AUTH_RESPONSE_LENGTH + 2) ||
strncmp((char *)msg, "S=", 2) != 0) { strncmp((char *)msg, "S=", 2) != 0) {
/* Packet does not start with "S=" */ /* Packet does not start with "S=" */
@ -363,7 +363,7 @@ static int chapms2_check_success(unsigned char *msg, int len, unsigned char *pri
msg += 2; msg += 2;
len -= 2; len -= 2;
if (len < MS_AUTH_RESPONSE_LENGTH if (len < MS_AUTH_RESPONSE_LENGTH
|| memcmp(msg, private, MS_AUTH_RESPONSE_LENGTH)) { || memcmp(msg, private_, MS_AUTH_RESPONSE_LENGTH)) {
/* Authenticator Response did not match expected. */ /* Authenticator Response did not match expected. */
ppp_error("MS-CHAPv2 mutual authentication failed."); ppp_error("MS-CHAPv2 mutual authentication failed.");
return 0; return 0;
@ -383,7 +383,8 @@ static int chapms2_check_success(unsigned char *msg, int len, unsigned char *pri
static void chapms_handle_failure(unsigned char *inp, int len) { static void chapms_handle_failure(unsigned char *inp, int len) {
int err; int err;
char *p, msg[64]; const char *p;
char msg[64];
/* We want a null-terminated string for strxxx(). */ /* We want a null-terminated string for strxxx(). */
len = LWIP_MIN(len, 63); len = LWIP_MIN(len, 63);

View File

@ -108,7 +108,7 @@ static void eap_lowerup(ppp_pcb *pcb);
static void eap_lowerdown(ppp_pcb *pcb); static void eap_lowerdown(ppp_pcb *pcb);
#if PRINTPKT_SUPPORT #if PRINTPKT_SUPPORT
static int eap_printpkt(u_char *inp, int inlen, static int eap_printpkt(u_char *inp, int inlen,
void (*)(void *arg, char *fmt, ...), void *arg); void (*)(void *arg, const char *fmt, ...), void *arg);
#endif /* PRINTPKT_SUPPORT */ #endif /* PRINTPKT_SUPPORT */
const struct protent eap_protent = { const struct protent eap_protent = {
@ -187,9 +187,7 @@ static void eap_server_timeout(void *arg);
/* /*
* Convert EAP state code to printable string for debug. * Convert EAP state code to printable string for debug.
*/ */
static const char * static const char * eap_state_name(enum eap_state_code esc)
eap_state_name(esc)
enum eap_state_code esc;
{ {
static const char *state_names[] = { EAP_STATES }; static const char *state_names[] = { EAP_STATES };
@ -266,7 +264,7 @@ static void eap_send_failure(ppp_pcb *pcb) {
return; return;
} }
outp = p->payload; outp = (u_char*)p->payload;
MAKEHEADER(outp, PPP_EAP); MAKEHEADER(outp, PPP_EAP);
@ -297,7 +295,7 @@ static void eap_send_success(ppp_pcb *pcb) {
return; return;
} }
outp = p->payload; outp = (u_char*)p->payload;
MAKEHEADER(outp, PPP_EAP); MAKEHEADER(outp, PPP_EAP);
@ -649,7 +647,7 @@ static void eap_send_request(ppp_pcb *pcb) {
u_char *ptr; u_char *ptr;
int outlen; int outlen;
int challen; int challen;
char *str; const char *str;
#ifdef USE_SRP #ifdef USE_SRP
struct t_server *ts; struct t_server *ts;
u_char clear[8], cipher[8], dig[SHA_DIGESTSIZE], *optr, *cp; u_char clear[8], cipher[8], dig[SHA_DIGESTSIZE], *optr, *cp;
@ -694,7 +692,7 @@ static void eap_send_request(ppp_pcb *pcb) {
return; return;
} }
outp = p->payload; outp = (u_char*)p->payload;
MAKEHEADER(outp, PPP_EAP); MAKEHEADER(outp, PPP_EAP);
@ -1056,7 +1054,7 @@ static void eap_send_response(ppp_pcb *pcb, u_char id, u_char typenum, u_char *s
return; return;
} }
outp = p->payload; outp = (u_char*)p->payload;
MAKEHEADER(outp, PPP_EAP); MAKEHEADER(outp, PPP_EAP);
@ -1090,7 +1088,7 @@ static void eap_chap_response(ppp_pcb *pcb, u_char id, u_char *hash, char *name,
return; return;
} }
outp = p->payload; outp = (u_char*)p->payload;
MAKEHEADER(outp, PPP_EAP); MAKEHEADER(outp, PPP_EAP);
@ -1208,7 +1206,7 @@ static void eap_send_nak(ppp_pcb *pcb, u_char id, u_char type) {
return; return;
} }
outp = p->payload; outp = (u_char*)p->payload;
MAKEHEADER(outp, PPP_EAP); MAKEHEADER(outp, PPP_EAP);
@ -1791,7 +1789,7 @@ static void eap_response(ppp_pcb *pcb, u_char *inp, int id, int len) {
#endif /* PPP_REMOTENAME */ #endif /* PPP_REMOTENAME */
) )
free(pcb->eap.es_server.ea_peer); free(pcb->eap.es_server.ea_peer);
pcb->eap.es_server.ea_peer = malloc(len + 1); pcb->eap.es_server.ea_peer = (char*)malloc(len + 1);
if (pcb->eap.es_server.ea_peer == NULL) { if (pcb->eap.es_server.ea_peer == NULL) {
pcb->eap.es_server.ea_peerlen = 0; pcb->eap.es_server.ea_peerlen = 0;
eap_figure_next_state(pcb, 1); eap_figure_next_state(pcb, 1);
@ -2151,11 +2149,11 @@ static void eap_input(ppp_pcb *pcb, u_char *inp, int inlen) {
/* /*
* eap_printpkt - print the contents of an EAP packet. * eap_printpkt - print the contents of an EAP packet.
*/ */
static char *eap_codenames[] = { static const char *eap_codenames[] = {
"Request", "Response", "Success", "Failure" "Request", "Response", "Success", "Failure"
}; };
static char *eap_typenames[] = { static const char *eap_typenames[] = {
"Identity", "Notification", "Nak", "MD5-Challenge", "Identity", "Notification", "Nak", "MD5-Challenge",
"OTP", "Generic-Token", NULL, NULL, "OTP", "Generic-Token", NULL, NULL,
"RSA", "DSS", "KEA", "KEA-Validate", "RSA", "DSS", "KEA", "KEA-Validate",
@ -2163,7 +2161,7 @@ static char *eap_typenames[] = {
"Cisco", "Nokia", "SRP" "Cisco", "Nokia", "SRP"
}; };
static int eap_printpkt(u_char *inp, int inlen, void (*printer) (void *, char *, ...), void *arg) { static int eap_printpkt(u_char *inp, int inlen, void (*printer) (void *, const char *, ...), void *arg) {
int code, id, len, rtype, vallen; int code, id, len, rtype, vallen;
u_char *pstart; u_char *pstart;
u32_t uval; u32_t uval;
@ -2316,8 +2314,12 @@ static int eap_printpkt(u_char *inp, int inlen, void (*printer) (void *, char *,
INCPTR(len, inp); INCPTR(len, inp);
len = 0; len = 0;
break; break;
default:
break;
} }
break; break;
default:
break;
} }
break; break;
@ -2421,13 +2423,18 @@ static int eap_printpkt(u_char *inp, int inlen, void (*printer) (void *, char *,
INCPTR(vallen, inp); INCPTR(vallen, inp);
len -= vallen; len -= vallen;
break; break;
default:
break;
} }
break; break;
default:
break;
} }
break; break;
case EAP_SUCCESS: /* No payload expected for these! */ case EAP_SUCCESS: /* No payload expected for these! */
case EAP_FAILURE: case EAP_FAILURE:
default:
break; break;
truncated: truncated:

View File

@ -186,6 +186,8 @@ void fsm_open(fsm *f) {
fsm_lowerup(f); fsm_lowerup(f);
} }
break; break;
default:
break;
} }
} }
@ -232,7 +234,7 @@ static void terminate_layer(fsm *f, int nextstate) {
* Cancel timeouts and either initiate close or possibly go directly to * Cancel timeouts and either initiate close or possibly go directly to
* the PPP_FSM_CLOSED state. * the PPP_FSM_CLOSED state.
*/ */
void fsm_close(fsm *f, char *reason) { void fsm_close(fsm *f, const char *reason) {
f->term_reason = reason; f->term_reason = reason;
f->term_reason_len = (reason == NULL? 0: LWIP_MIN(strlen(reason), 0xFF) ); f->term_reason_len = (reason == NULL? 0: LWIP_MIN(strlen(reason), 0xFF) );
switch( f->state ){ switch( f->state ){
@ -252,6 +254,8 @@ void fsm_close(fsm *f, char *reason) {
case PPP_FSM_OPENED: case PPP_FSM_OPENED:
terminate_layer(f, PPP_FSM_CLOSING); terminate_layer(f, PPP_FSM_CLOSING);
break; break;
default:
break;
} }
} }
@ -410,6 +414,8 @@ static void fsm_rconfreq(fsm *f, u_char id, u_char *inp, int len) {
fsm_sconfreq(f, 0); /* Send initial Configure-Request */ fsm_sconfreq(f, 0); /* Send initial Configure-Request */
f->state = PPP_FSM_REQSENT; f->state = PPP_FSM_REQSENT;
break; break;
default:
break;
} }
/* /*
@ -497,6 +503,8 @@ static void fsm_rconfack(fsm *f, int id, u_char *inp, int len) {
fsm_sconfreq(f, 0); /* Send initial Configure-Request */ fsm_sconfreq(f, 0); /* Send initial Configure-Request */
f->state = PPP_FSM_REQSENT; f->state = PPP_FSM_REQSENT;
break; break;
default:
break;
} }
} }
@ -560,6 +568,8 @@ static void fsm_rconfnakrej(fsm *f, int code, int id, u_char *inp, int len) {
fsm_sconfreq(f, 0); /* Send initial Configure-Request */ fsm_sconfreq(f, 0); /* Send initial Configure-Request */
f->state = PPP_FSM_REQSENT; f->state = PPP_FSM_REQSENT;
break; break;
default:
break;
} }
} }
@ -587,6 +597,8 @@ static void fsm_rtermreq(fsm *f, int id, u_char *p, int len) {
(*f->callbacks->down)(f); /* Inform upper layers */ (*f->callbacks->down)(f); /* Inform upper layers */
TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time); TIMEOUT(fsm_timeout, f, pcb->settings.fsm_timeout_time);
break; break;
default:
break;
} }
fsm_sdata(f, TERMACK, id, NULL, 0); fsm_sdata(f, TERMACK, id, NULL, 0);
@ -621,6 +633,8 @@ static void fsm_rtermack(fsm *f) {
fsm_sconfreq(f, 0); fsm_sconfreq(f, 0);
f->state = PPP_FSM_REQSENT; f->state = PPP_FSM_REQSENT;
break; break;
default:
break;
} }
} }
@ -730,7 +744,7 @@ static void fsm_sconfreq(fsm *f, int retransmit) {
} }
/* send the request to our peer */ /* send the request to our peer */
outp = p->payload; outp = (u_char*)p->payload;
MAKEHEADER(outp, f->protocol); MAKEHEADER(outp, f->protocol);
PUTCHAR(CONFREQ, outp); PUTCHAR(CONFREQ, outp);
PUTCHAR(f->reqid, outp); PUTCHAR(f->reqid, outp);
@ -771,7 +785,7 @@ void fsm_sdata(fsm *f, u_char code, u_char id, u_char *data, int datalen) {
return; return;
} }
outp = p->payload; outp = (u_char*)p->payload;
/* if (datalen && data != outp + PPP_HDRLEN + HEADERLEN) -- was only for fsm_sconfreq() */ /* if (datalen && data != outp + PPP_HDRLEN + HEADERLEN) -- was only for fsm_sconfreq() */
MEMCPY(outp + PPP_HDRLEN + HEADERLEN, data, datalen); MEMCPY(outp + PPP_HDRLEN + HEADERLEN, data, datalen);
MAKEHEADER(outp, f->protocol); MAKEHEADER(outp, f->protocol);

View File

@ -258,14 +258,14 @@ static option_t ipcp_option_list[] = {
*/ */
static void ipcp_init(ppp_pcb *pcb); static void ipcp_init(ppp_pcb *pcb);
static void ipcp_open(ppp_pcb *pcb); static void ipcp_open(ppp_pcb *pcb);
static void ipcp_close(ppp_pcb *pcb, char *reason); static void ipcp_close(ppp_pcb *pcb, const char *reason);
static void ipcp_lowerup(ppp_pcb *pcb); static void ipcp_lowerup(ppp_pcb *pcb);
static void ipcp_lowerdown(ppp_pcb *pcb); static void ipcp_lowerdown(ppp_pcb *pcb);
static void ipcp_input(ppp_pcb *pcb, u_char *p, int len); static void ipcp_input(ppp_pcb *pcb, u_char *p, int len);
static void ipcp_protrej(ppp_pcb *pcb); static void ipcp_protrej(ppp_pcb *pcb);
#if PRINTPKT_SUPPORT #if PRINTPKT_SUPPORT
static int ipcp_printpkt(u_char *p, int plen, static int ipcp_printpkt(u_char *p, int plen,
void (*printer) (void *, char *, ...), void *arg); void (*printer) (void *, const char *, ...), void *arg);
#endif /* PRINTPKT_SUPPORT */ #endif /* PRINTPKT_SUPPORT */
#if PPP_OPTIONS #if PPP_OPTIONS
static void ip_check_options (void); static void ip_check_options (void);
@ -657,7 +657,7 @@ static void ipcp_open(ppp_pcb *pcb) {
/* /*
* ipcp_close - Take IPCP down. * ipcp_close - Take IPCP down.
*/ */
static void ipcp_close(ppp_pcb *pcb, char *reason) { static void ipcp_close(ppp_pcb *pcb, const char *reason) {
fsm *f = &pcb->ipcp_fsm; fsm *f = &pcb->ipcp_fsm;
fsm_close(f, reason); fsm_close(f, reason);
} }
@ -1031,10 +1031,10 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
u_short cishort; u_short cishort;
u32_t ciaddr1, ciaddr2, l, cidnsaddr; u32_t ciaddr1, ciaddr2, l, cidnsaddr;
ipcp_options no; /* options we've seen Naks for */ ipcp_options no; /* options we've seen Naks for */
ipcp_options try; /* options to request next time */ ipcp_options try_; /* options to request next time */
BZERO(&no, sizeof(no)); BZERO(&no, sizeof(no));
try = *go; try_ = *go;
/* /*
* Any Nak'd CIs must be in exactly the same order that we sent. * Any Nak'd CIs must be in exactly the same order that we sent.
@ -1100,15 +1100,15 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
*/ */
NAKCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, NAKCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs,
if (treat_as_reject) { if (treat_as_reject) {
try.old_addrs = 0; try_.old_addrs = 0;
} else { } else {
if (go->accept_local && ciaddr1) { if (go->accept_local && ciaddr1) {
/* take his idea of our address */ /* take his idea of our address */
try.ouraddr = ciaddr1; try_.ouraddr = ciaddr1;
} }
if (go->accept_remote && ciaddr2) { if (go->accept_remote && ciaddr2) {
/* take his idea of his address */ /* take his idea of his address */
try.hisaddr = ciaddr2; try_.hisaddr = ciaddr2;
} }
} }
); );
@ -1121,52 +1121,52 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
*/ */
NAKCIVJ(CI_COMPRESSTYPE, neg_vj, NAKCIVJ(CI_COMPRESSTYPE, neg_vj,
if (treat_as_reject) { if (treat_as_reject) {
try.neg_vj = 0; try_.neg_vj = 0;
} else if (cilen == CILEN_VJ) { } else if (cilen == CILEN_VJ) {
GETCHAR(cimaxslotindex, p); GETCHAR(cimaxslotindex, p);
GETCHAR(cicflag, p); GETCHAR(cicflag, p);
if (cishort == IPCP_VJ_COMP) { if (cishort == IPCP_VJ_COMP) {
try.old_vj = 0; try_.old_vj = 0;
if (cimaxslotindex < go->maxslotindex) if (cimaxslotindex < go->maxslotindex)
try.maxslotindex = cimaxslotindex; try_.maxslotindex = cimaxslotindex;
if (!cicflag) if (!cicflag)
try.cflag = 0; try_.cflag = 0;
} else { } else {
try.neg_vj = 0; try_.neg_vj = 0;
} }
} else { } else {
if (cishort == IPCP_VJ_COMP || cishort == IPCP_VJ_COMP_OLD) { if (cishort == IPCP_VJ_COMP || cishort == IPCP_VJ_COMP_OLD) {
try.old_vj = 1; try_.old_vj = 1;
try.vj_protocol = cishort; try_.vj_protocol = cishort;
} else { } else {
try.neg_vj = 0; try_.neg_vj = 0;
} }
} }
); );
NAKCIADDR(CI_ADDR, neg_addr, NAKCIADDR(CI_ADDR, neg_addr,
if (treat_as_reject) { if (treat_as_reject) {
try.neg_addr = 0; try_.neg_addr = 0;
try.old_addrs = 0; try_.old_addrs = 0;
} else if (go->accept_local && ciaddr1) { } else if (go->accept_local && ciaddr1) {
/* take his idea of our address */ /* take his idea of our address */
try.ouraddr = ciaddr1; try_.ouraddr = ciaddr1;
} }
); );
NAKCIDNS(CI_MS_DNS1, req_dns1, NAKCIDNS(CI_MS_DNS1, req_dns1,
if (treat_as_reject) { if (treat_as_reject) {
try.req_dns1 = 0; try_.req_dns1 = 0;
} else { } else {
try.dnsaddr[0] = cidnsaddr; try_.dnsaddr[0] = cidnsaddr;
} }
); );
NAKCIDNS(CI_MS_DNS2, req_dns2, NAKCIDNS(CI_MS_DNS2, req_dns2,
if (treat_as_reject) { if (treat_as_reject) {
try.req_dns2 = 0; try_.req_dns2 = 0;
} else { } else {
try.dnsaddr[1] = cidnsaddr; try_.dnsaddr[1] = cidnsaddr;
} }
); );
@ -1196,43 +1196,43 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
if ((!go->neg_addr && go->old_addrs) || no.old_addrs if ((!go->neg_addr && go->old_addrs) || no.old_addrs
|| cilen != CILEN_ADDRS) || cilen != CILEN_ADDRS)
goto bad; goto bad;
try.neg_addr = 0; try_.neg_addr = 0;
GETLONG(l, p); GETLONG(l, p);
ciaddr1 = htonl(l); ciaddr1 = htonl(l);
if (ciaddr1 && go->accept_local) if (ciaddr1 && go->accept_local)
try.ouraddr = ciaddr1; try_.ouraddr = ciaddr1;
GETLONG(l, p); GETLONG(l, p);
ciaddr2 = htonl(l); ciaddr2 = htonl(l);
if (ciaddr2 && go->accept_remote) if (ciaddr2 && go->accept_remote)
try.hisaddr = ciaddr2; try_.hisaddr = ciaddr2;
no.old_addrs = 1; no.old_addrs = 1;
break; break;
case CI_ADDR: case CI_ADDR:
if (go->neg_addr || no.neg_addr || cilen != CILEN_ADDR) if (go->neg_addr || no.neg_addr || cilen != CILEN_ADDR)
goto bad; goto bad;
try.old_addrs = 0; try_.old_addrs = 0;
GETLONG(l, p); GETLONG(l, p);
ciaddr1 = htonl(l); ciaddr1 = htonl(l);
if (ciaddr1 && go->accept_local) if (ciaddr1 && go->accept_local)
try.ouraddr = ciaddr1; try_.ouraddr = ciaddr1;
if (try.ouraddr != 0) if (try_.ouraddr != 0)
try.neg_addr = 1; try_.neg_addr = 1;
no.neg_addr = 1; no.neg_addr = 1;
break; break;
case CI_MS_DNS1: case CI_MS_DNS1:
if (go->req_dns1 || no.req_dns1 || cilen != CILEN_ADDR) if (go->req_dns1 || no.req_dns1 || cilen != CILEN_ADDR)
goto bad; goto bad;
GETLONG(l, p); GETLONG(l, p);
try.dnsaddr[0] = htonl(l); try_.dnsaddr[0] = htonl(l);
try.req_dns1 = 1; try_.req_dns1 = 1;
no.req_dns1 = 1; no.req_dns1 = 1;
break; break;
case CI_MS_DNS2: case CI_MS_DNS2:
if (go->req_dns2 || no.req_dns2 || cilen != CILEN_ADDR) if (go->req_dns2 || no.req_dns2 || cilen != CILEN_ADDR)
goto bad; goto bad;
GETLONG(l, p); GETLONG(l, p);
try.dnsaddr[1] = htonl(l); try_.dnsaddr[1] = htonl(l);
try.req_dns2 = 1; try_.req_dns2 = 1;
no.req_dns2 = 1; no.req_dns2 = 1;
break; break;
case CI_MS_WINS1: case CI_MS_WINS1:
@ -1242,7 +1242,9 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
GETLONG(l, p); GETLONG(l, p);
ciaddr1 = htonl(l); ciaddr1 = htonl(l);
if (ciaddr1) if (ciaddr1)
try.winsaddr[citype == CI_MS_WINS2] = ciaddr1; try_.winsaddr[citype == CI_MS_WINS2] = ciaddr1;
break;
default:
break; break;
} }
p = next; p = next;
@ -1253,7 +1255,7 @@ static int ipcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
* If there are any remaining options, we ignore them. * If there are any remaining options, we ignore them.
*/ */
if (f->state != PPP_FSM_OPENED) if (f->state != PPP_FSM_OPENED)
*go = try; *go = try_;
return 1; return 1;
@ -1273,9 +1275,9 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) {
u_char cimaxslotindex, ciflag, cilen; u_char cimaxslotindex, ciflag, cilen;
u_short cishort; u_short cishort;
u32_t cilong; u32_t cilong;
ipcp_options try; /* options to request next time */ ipcp_options try_; /* options to request next time */
try = *go; try_ = *go;
/* /*
* Any Rejected CIs must be in exactly the same order that we sent. * Any Rejected CIs must be in exactly the same order that we sent.
* Check packet length and CI length at each step. * Check packet length and CI length at each step.
@ -1299,7 +1301,7 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) {
/* Check rejected value. */ \ /* Check rejected value. */ \
if (cilong != val2) \ if (cilong != val2) \
goto bad; \ goto bad; \
try.old_addrs = 0; \ try_.old_addrs = 0; \
} }
#define REJCIVJ(opt, neg, val, old, maxslot, cflag) \ #define REJCIVJ(opt, neg, val, old, maxslot, cflag) \
@ -1321,7 +1323,7 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) {
if (ciflag != cflag) \ if (ciflag != cflag) \
goto bad; \ goto bad; \
} \ } \
try.neg = 0; \ try_.neg = 0; \
} }
#define REJCIADDR(opt, neg, val) \ #define REJCIADDR(opt, neg, val) \
@ -1337,7 +1339,7 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) {
/* Check rejected value. */ \ /* Check rejected value. */ \
if (cilong != val) \ if (cilong != val) \
goto bad; \ goto bad; \
try.neg = 0; \ try_.neg = 0; \
} }
#define REJCIDNS(opt, neg, dnsaddr) \ #define REJCIDNS(opt, neg, dnsaddr) \
@ -1353,7 +1355,7 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) {
/* Check rejected value. */ \ /* Check rejected value. */ \
if (cilong != dnsaddr) \ if (cilong != dnsaddr) \
goto bad; \ goto bad; \
try.neg = 0; \ try_.neg = 0; \
} }
#define REJCIWINS(opt, addr) \ #define REJCIWINS(opt, addr) \
@ -1369,7 +1371,7 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) {
/* Check rejected value. */ \ /* Check rejected value. */ \
if (cilong != addr) \ if (cilong != addr) \
goto bad; \ goto bad; \
try.winsaddr[opt == CI_MS_WINS2] = 0; \ try_.winsaddr[opt == CI_MS_WINS2] = 0; \
} }
REJCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs, REJCIADDRS(CI_ADDRS, !go->neg_addr && go->old_addrs,
@ -1397,7 +1399,7 @@ static int ipcp_rejci(fsm *f, u_char *p, int len) {
* Now we can update state. * Now we can update state.
*/ */
if (f->state != PPP_FSM_OPENED) if (f->state != PPP_FSM_OPENED)
*go = try; *go = try_;
return 1; return 1;
bad: bad:
@ -2093,13 +2095,13 @@ create_resolv(peerdns1, peerdns2)
/* /*
* ipcp_printpkt - print the contents of an IPCP packet. * ipcp_printpkt - print the contents of an IPCP packet.
*/ */
static char *ipcp_codenames[] = { static const char *ipcp_codenames[] = {
"ConfReq", "ConfAck", "ConfNak", "ConfRej", "ConfReq", "ConfAck", "ConfNak", "ConfRej",
"TermReq", "TermAck", "CodeRej" "TermReq", "TermAck", "CodeRej"
}; };
static int ipcp_printpkt(u_char *p, int plen, static int ipcp_printpkt(u_char *p, int plen,
void (*printer) (void *, char *, ...), void *arg) { void (*printer) (void *, const char *, ...), void *arg) {
int code, id, len, olen; int code, id, len, olen;
u_char *pstart, *optend; u_char *pstart, *optend;
u_short cishort; u_short cishort;
@ -2183,6 +2185,8 @@ static int ipcp_printpkt(u_char *p, int plen,
GETLONG(cilong, p); GETLONG(cilong, p);
printer(arg, "ms-wins %I", htonl(cilong)); printer(arg, "ms-wins %I", htonl(cilong));
break; break;
default:
break;
} }
while (p < optend) { while (p < optend) {
GETCHAR(code, p); GETCHAR(code, p);
@ -2201,6 +2205,8 @@ static int ipcp_printpkt(u_char *p, int plen,
len = 0; len = 0;
} }
break; break;
default:
break;
} }
/* print the rest of the bytes in the packet */ /* print the rest of the bytes in the packet */

View File

@ -255,7 +255,7 @@ static option_t ipv6cp_option_list[] = {
*/ */
static void ipv6cp_init(ppp_pcb *pcb); static void ipv6cp_init(ppp_pcb *pcb);
static void ipv6cp_open(ppp_pcb *pcb); static void ipv6cp_open(ppp_pcb *pcb);
static void ipv6cp_close(ppp_pcb *pcb, char *reason); static void ipv6cp_close(ppp_pcb *pcb, const char *reason);
static void ipv6cp_lowerup(ppp_pcb *pcb); static void ipv6cp_lowerup(ppp_pcb *pcb);
static void ipv6cp_lowerdown(ppp_pcb *pcb); static void ipv6cp_lowerdown(ppp_pcb *pcb);
static void ipv6cp_input(ppp_pcb *pcb, u_char *p, int len); static void ipv6cp_input(ppp_pcb *pcb, u_char *p, int len);
@ -462,7 +462,7 @@ static void ipv6cp_open(ppp_pcb *pcb) {
/* /*
* ipv6cp_close - Take IPV6CP down. * ipv6cp_close - Take IPV6CP down.
*/ */
static void ipv6cp_close(ppp_pcb *pcb, char *reason) { static void ipv6cp_close(ppp_pcb *pcb, const char *reason) {
fsm_close(&pcb->ipv6cp_fsm, reason); fsm_close(&pcb->ipv6cp_fsm, reason);
} }

View File

@ -269,7 +269,7 @@ static void lcp_input(ppp_pcb *pcb, u_char *p, int len);
static void lcp_protrej(ppp_pcb *pcb); static void lcp_protrej(ppp_pcb *pcb);
#if PRINTPKT_SUPPORT #if PRINTPKT_SUPPORT
static int lcp_printpkt(u_char *p, int plen, static int lcp_printpkt(u_char *p, int plen,
void (*printer) (void *, char *, ...), void *arg); void (*printer) (void *, const char *, ...), void *arg);
#endif /* PRINTPKT_SUPPORT */ #endif /* PRINTPKT_SUPPORT */
const struct protent lcp_protent = { const struct protent lcp_protent = {
@ -436,7 +436,7 @@ void lcp_open(ppp_pcb *pcb) {
/* /*
* lcp_close - Take LCP down. * lcp_close - Take LCP down.
*/ */
void lcp_close(ppp_pcb *pcb, char *reason) { void lcp_close(ppp_pcb *pcb, const char *reason) {
fsm *f = &pcb->lcp_fsm; fsm *f = &pcb->lcp_fsm;
int oldstate; int oldstate;
@ -525,7 +525,7 @@ void lcp_lowerdown(ppp_pcb *pcb) {
* lcp_delayed_up - Bring the lower layer up now. * lcp_delayed_up - Bring the lower layer up now.
*/ */
static void lcp_delayed_up(void *arg) { static void lcp_delayed_up(void *arg) {
fsm *f = arg; fsm *f = (fsm*)arg;
if (f->flags & DELAYED_UP) { if (f->flags & DELAYED_UP) {
f->flags &= ~DELAYED_UP; f->flags &= ~DELAYED_UP;
@ -1487,6 +1487,8 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
if (go->neg_endpoint || no.neg_endpoint || cilen < CILEN_CHAR) if (go->neg_endpoint || no.neg_endpoint || cilen < CILEN_CHAR)
goto bad; goto bad;
break; break;
default:
break;
} }
p = next; p = next;
} }
@ -1790,7 +1792,7 @@ static int lcp_reqci(fsm *f, u_char *inp, int *lenp, int reject_if_disagree) {
return 0; return 0;
} }
nakoutp = nakp->payload; nakoutp = (u_char*)nakp->payload;
rejp = inp; rejp = inp;
while (l) { while (l) {
orc = CONFACK; /* Assume success */ orc = CONFACK; /* Assume success */
@ -2213,6 +2215,8 @@ endswitch:
case CONFREJ: case CONFREJ:
*lenp = rejp - inp; *lenp = rejp - inp;
break; break;
default:
break;
} }
pbuf_free(nakp); pbuf_free(nakp);
@ -2311,7 +2315,7 @@ static void lcp_finished(fsm *f) {
/* /*
* lcp_printpkt - print the contents of an LCP packet. * lcp_printpkt - print the contents of an LCP packet.
*/ */
static char *lcp_codenames[] = { static const char *lcp_codenames[] = {
"ConfReq", "ConfAck", "ConfNak", "ConfRej", "ConfReq", "ConfAck", "ConfNak", "ConfRej",
"TermReq", "TermAck", "CodeRej", "ProtRej", "TermReq", "TermAck", "CodeRej", "ProtRej",
"EchoReq", "EchoRep", "DiscReq", "Ident", "EchoReq", "EchoRep", "DiscReq", "Ident",
@ -2319,7 +2323,7 @@ static char *lcp_codenames[] = {
}; };
static int lcp_printpkt(u_char *p, int plen, static int lcp_printpkt(u_char *p, int plen,
void (*printer) (void *, char *, ...), void *arg) { void (*printer) (void *, const char *, ...), void *arg) {
int code, id, len, olen, i; int code, id, len, olen, i;
u_char *pstart, *optend; u_char *pstart, *optend;
u_short cishort; u_short cishort;
@ -2402,6 +2406,8 @@ static int lcp_printpkt(u_char *p, int plen,
++p; ++p;
break; break;
#endif /* MSCHAP_SUPPORT */ #endif /* MSCHAP_SUPPORT */
default:
break;
} }
} }
break; break;
@ -2497,6 +2503,8 @@ static int lcp_printpkt(u_char *p, int plen,
printer(arg, "endpoint"); printer(arg, "endpoint");
#endif #endif
break; break;
default:
break;
} }
while (p < optend) { while (p < optend) {
GETCHAR(code, p); GETCHAR(code, p);
@ -2547,6 +2555,8 @@ static int lcp_printpkt(u_char *p, int plen,
len = 0; len = 0;
} }
break; break;
default:
break;
} }
/* print the rest of the bytes in the packet */ /* print the rest of the bytes in the packet */

View File

@ -109,7 +109,7 @@ static long magic_randcount = 0; /* Pseudo-random incrementer */
* *
* Ref: Applied Cryptography 2nd Ed. by Bruce Schneier p. 427 * Ref: Applied Cryptography 2nd Ed. by Bruce Schneier p. 427
*/ */
void magic_churnrand(char *rand_data, u32_t rand_len) { static void magic_churnrand(char *rand_data, u32_t rand_len) {
md5_context md5; md5_context md5;
/* LWIP_DEBUGF(LOG_INFO, ("magic_churnrand: %u@%P\n", rand_len, rand_data)); */ /* LWIP_DEBUGF(LOG_INFO, ("magic_churnrand: %u@%P\n", rand_len, rand_data)); */
@ -133,7 +133,7 @@ void magic_churnrand(char *rand_data, u32_t rand_len) {
/* /*
* Initialize the random number generator. * Initialize the random number generator.
*/ */
void magic_init() { void magic_init(void) {
magic_churnrand(NULL, 0); magic_churnrand(NULL, 0);
} }
@ -183,7 +183,7 @@ void random_bytes(unsigned char *buf, u32_t buf_len) {
/* /*
* Return a new random number. * Return a new random number.
*/ */
u32_t magic() { u32_t magic(void) {
u32_t new_rand; u32_t new_rand;
random_bytes((unsigned char *)&new_rand, sizeof(new_rand)); random_bytes((unsigned char *)&new_rand, sizeof(new_rand));

View File

@ -674,7 +674,7 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
protocol = (((u8_t *)pb->payload)[0] << 8) | ((u8_t*)pb->payload)[1]; protocol = (((u8_t *)pb->payload)[0] << 8) | ((u8_t*)pb->payload)[1];
#if PRINTPKT_SUPPORT #if PRINTPKT_SUPPORT
ppp_dump_packet("rcvd", pb->payload, pb->len); ppp_dump_packet("rcvd", (unsigned char *)pb->payload, pb->len);
#endif /* PRINTPKT_SUPPORT */ #endif /* PRINTPKT_SUPPORT */
if(pbuf_header(pb, -(s16_t)sizeof(protocol))) { if(pbuf_header(pb, -(s16_t)sizeof(protocol))) {
@ -774,7 +774,7 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
for (i = 0; (protp = protocols[i]) != NULL; ++i) { for (i = 0; (protp = protocols[i]) != NULL; ++i) {
if (protp->protocol == protocol && protp->enabled_flag) { if (protp->protocol == protocol && protp->enabled_flag) {
pb = ppp_singlebuf(pb); pb = ppp_singlebuf(pb);
(*protp->input)(pcb, pb->payload, pb->len); (*protp->input)(pcb, (u_char*)pb->payload, pb->len);
goto out; goto out;
} }
#if 0 /* UNUSED #if 0 /* UNUSED
@ -807,7 +807,7 @@ void ppp_input(ppp_pcb *pcb, struct pbuf *pb) {
LWIP_ASSERT("pbuf_header failed\n", 0); LWIP_ASSERT("pbuf_header failed\n", 0);
goto drop; goto drop;
} }
lcp_sprotrej(pcb, pb->payload, pb->len); lcp_sprotrej(pcb, (u_char*)pb->payload, pb->len);
} }
break; break;
} }
@ -948,7 +948,7 @@ pppos_put(ppp_pcb *pcb, struct pbuf *nb)
int c; int c;
for(b = nb; b != NULL; b = b->next) { for(b = nb; b != NULL; b = b->next) {
c = sio_write(pcb->fd, b->payload, b->len); c = sio_write(pcb->fd, (u8_t*)b->payload, b->len);
if(c != b->len) { if(c != b->len) {
PPPDEBUG(LOG_WARNING, PPPDEBUG(LOG_WARNING,
("PPP pppos_put: incomplete sio_write(fd:%"SZT_F", len:%d, c: 0x%"X8_F") c = %d\n", (size_t)pcb->fd, b->len, c, c)); ("PPP pppos_put: incomplete sio_write(fd:%"SZT_F", len:%d, c: 0x%"X8_F") c = %d\n", (size_t)pcb->fd, b->len, c, c));
@ -1187,7 +1187,9 @@ static err_t ppp_netif_output_over_serial(ppp_pcb *pcb, struct pbuf *pb, u_short
static err_t ppp_netif_output_over_ethernet(ppp_pcb *pcb, struct pbuf *p, u_short protocol) { static err_t ppp_netif_output_over_ethernet(ppp_pcb *pcb, struct pbuf *p, u_short protocol) {
struct pbuf *pb; struct pbuf *pb;
int i=0; int i=0;
#if LWIP_SNMP
u16_t tot_len; u16_t tot_len;
#endif /* LWIP_SNMP */
err_t err; err_t err;
/* @todo: try to use pbuf_header() here! */ /* @todo: try to use pbuf_header() here! */
@ -1209,7 +1211,9 @@ static err_t ppp_netif_output_over_ethernet(ppp_pcb *pcb, struct pbuf *p, u_shor
*((u_char*)pb->payload + i) = protocol & 0xFF; *((u_char*)pb->payload + i) = protocol & 0xFF;
pbuf_chain(pb, p); pbuf_chain(pb, p);
#if LWIP_SNMP
tot_len = pb->tot_len; tot_len = pb->tot_len;
#endif /* LWIP_SNMP */
if( (err = pppoe_xmit(pcb->pppoe_sc, pb)) != ERR_OK) { if( (err = pppoe_xmit(pcb->pppoe_sc, pb)) != ERR_OK) {
LINK_STATS_INC(link.err); LINK_STATS_INC(link.err);
@ -1229,7 +1233,9 @@ static err_t ppp_netif_output_over_ethernet(ppp_pcb *pcb, struct pbuf *p, u_shor
static err_t ppp_netif_output_over_l2tp(ppp_pcb *pcb, struct pbuf *p, u_short protocol) { static err_t ppp_netif_output_over_l2tp(ppp_pcb *pcb, struct pbuf *p, u_short protocol) {
struct pbuf *pb; struct pbuf *pb;
int i=0; int i=0;
#if LWIP_SNMP
u16_t tot_len; u16_t tot_len;
#endif /* LWIP_SNMP */
err_t err; err_t err;
/* @todo: try to use pbuf_header() here! */ /* @todo: try to use pbuf_header() here! */
@ -1251,7 +1257,9 @@ static err_t ppp_netif_output_over_l2tp(ppp_pcb *pcb, struct pbuf *p, u_short pr
*((u_char*)pb->payload + i) = protocol & 0xFF; *((u_char*)pb->payload + i) = protocol & 0xFF;
pbuf_chain(pb, p); pbuf_chain(pb, p);
#if LWIP_SNMP
tot_len = pb->tot_len; tot_len = pb->tot_len;
#endif /* LWIP_SNMP */
if( (err = pppol2tp_xmit(pcb->l2tp_pcb, pb)) != ERR_OK) { if( (err = pppol2tp_xmit(pcb->l2tp_pcb, pb)) != ERR_OK) {
LINK_STATS_INC(link.err); LINK_STATS_INC(link.err);
@ -1309,6 +1317,9 @@ ppp_ioctl(ppp_pcb *pcb, int cmd, void *arg)
return PPPERR_PARAM; return PPPERR_PARAM;
break; break;
#endif /* PPPOS_SUPPORT */ #endif /* PPPOS_SUPPORT */
default:
break;
} }
return PPPERR_PARAM; return PPPERR_PARAM;
@ -1354,7 +1365,7 @@ int ppp_write(ppp_pcb *pcb, struct pbuf *p) {
#if PPPOS_SUPPORT #if PPPOS_SUPPORT
static int ppp_write_over_serial(ppp_pcb *pcb, struct pbuf *p) { static int ppp_write_over_serial(ppp_pcb *pcb, struct pbuf *p) {
u_char *s = p->payload; u_char *s = (u_char*)p->payload;
int n = p->len; int n = p->len;
u_char c; u_char c;
u_int fcs_out; u_int fcs_out;
@ -1422,7 +1433,9 @@ static int ppp_write_over_serial(ppp_pcb *pcb, struct pbuf *p) {
#if PPPOE_SUPPORT #if PPPOE_SUPPORT
static int ppp_write_over_ethernet(ppp_pcb *pcb, struct pbuf *p) { static int ppp_write_over_ethernet(ppp_pcb *pcb, struct pbuf *p) {
struct pbuf *ph; /* Ethernet + PPPoE header */ struct pbuf *ph; /* Ethernet + PPPoE header */
#if LWIP_SNMP
u16_t tot_len; u16_t tot_len;
#endif /* LWIP_SNMP */
/* skip address & flags */ /* skip address & flags */
pbuf_header(p, -(s16_t)2); pbuf_header(p, -(s16_t)2);
@ -1438,7 +1451,9 @@ static int ppp_write_over_ethernet(ppp_pcb *pcb, struct pbuf *p) {
pbuf_header(ph, -(s16_t)PPPOE_HEADERLEN); /* hide PPPoE header */ pbuf_header(ph, -(s16_t)PPPOE_HEADERLEN); /* hide PPPoE header */
pbuf_cat(ph, p); pbuf_cat(ph, p);
#if LWIP_SNMP
tot_len = ph->tot_len; tot_len = ph->tot_len;
#endif /* LWIP_SNMP */
pcb->last_xmit = sys_jiffies(); pcb->last_xmit = sys_jiffies();
@ -1458,7 +1473,9 @@ static int ppp_write_over_ethernet(ppp_pcb *pcb, struct pbuf *p) {
#if PPPOL2TP_SUPPORT #if PPPOL2TP_SUPPORT
static int ppp_write_over_l2tp(ppp_pcb *pcb, struct pbuf *p) { static int ppp_write_over_l2tp(ppp_pcb *pcb, struct pbuf *p) {
struct pbuf *ph; /* UDP + L2TP header */ struct pbuf *ph; /* UDP + L2TP header */
#if LWIP_SNMP
u16_t tot_len; u16_t tot_len;
#endif /* LWIP_SNMP */
ph = pbuf_alloc(PBUF_TRANSPORT, (u16_t)(PPPOL2TP_OUTPUT_DATA_HEADER_LEN), PBUF_RAM); ph = pbuf_alloc(PBUF_TRANSPORT, (u16_t)(PPPOL2TP_OUTPUT_DATA_HEADER_LEN), PBUF_RAM);
if(!ph) { if(!ph) {
@ -1471,7 +1488,9 @@ static int ppp_write_over_l2tp(ppp_pcb *pcb, struct pbuf *p) {
pbuf_header(ph, -(s16_t)PPPOL2TP_OUTPUT_DATA_HEADER_LEN); /* hide L2TP header */ pbuf_header(ph, -(s16_t)PPPOL2TP_OUTPUT_DATA_HEADER_LEN); /* hide L2TP header */
pbuf_cat(ph, p); pbuf_cat(ph, p);
#if LWIP_SNMP
tot_len = ph->tot_len; tot_len = ph->tot_len;
#endif /* LWIP_SNMP */
pcb->last_xmit = sys_jiffies(); pcb->last_xmit = sys_jiffies();
@ -1763,6 +1782,8 @@ pppos_input(ppp_pcb *pcb, u_char *s, int l)
/* Load character into buffer. */ /* Load character into buffer. */
((u_char*)pcrx->in_tail->payload)[pcrx->in_tail->len++] = cur_char; ((u_char*)pcrx->in_tail->payload)[pcrx->in_tail->len++] = cur_char;
break; break;
default:
break;
} }
/* update the frame check sequence number. */ /* update the frame check sequence number. */
@ -1814,7 +1835,7 @@ struct pbuf * ppp_singlebuf(struct pbuf *p) {
return p; /* live dangerously */ return p; /* live dangerously */
} }
for(b = p, pl = q->payload; b != NULL; b = b->next) { for(b = p, pl = (u_char*)q->payload; b != NULL; b = b->next) {
MEMCPY(pl, b->payload, b->len); MEMCPY(pl, b->payload, b->len);
pl += b->len; pl += b->len;
} }
@ -1848,6 +1869,9 @@ static void ppp_over_ethernet_link_status_cb(ppp_pcb *pcb, int state) {
pppoe_err_code = PPPERR_OPEN; pppoe_err_code = PPPERR_OPEN;
new_phase(pcb, PPP_PHASE_DEAD); new_phase(pcb, PPP_PHASE_DEAD);
break; break;
default:
break;
} }
pcb->link_status_cb(pcb, pcb->err_code ? pcb->err_code : pppoe_err_code, pcb->ctx_cb); pcb->link_status_cb(pcb, pcb->err_code ? pcb->err_code : pppoe_err_code, pcb->ctx_cb);
@ -1898,6 +1922,9 @@ static void ppp_over_l2tp_link_status_cb(ppp_pcb *pcb, int state) {
pppol2tp_err_code = PPPERR_OPEN; pppol2tp_err_code = PPPERR_OPEN;
new_phase(pcb, PPP_PHASE_DEAD); new_phase(pcb, PPP_PHASE_DEAD);
break; break;
default:
break;
} }
pcb->link_status_cb(pcb, pcb->err_code ? pcb->err_code : pppol2tp_err_code, pcb->ctx_cb); pcb->link_status_cb(pcb, pcb->err_code ? pcb->err_code : pppol2tp_err_code, pcb->ctx_cb);
@ -1947,7 +1974,7 @@ void ppp_link_terminated(ppp_pcb *pcb) {
/* We cannot call ppp_free_current_input_packet() here because /* We cannot call ppp_free_current_input_packet() here because
* rx thread might still call pppos_input() * rx thread might still call pppos_input()
*/ */
PPPDEBUG(LOG_DEBUG, ("ppp_link_terminated: unit %d: link_status_cb=%p err_code=%d\n", pcb->num, pcb->link_status_cb, pcb->err_code)); PPPDEBUG(LOG_DEBUG, ("ppp_link_terminated: unit %d: err_code=%d\n", pcb->num, pcb->err_code));
pcb->link_status_cb(pcb, pcb->err_code ? pcb->err_code : PPPERR_PROTOCOL, pcb->ctx_cb); pcb->link_status_cb(pcb, pcb->err_code ? pcb->err_code : PPPERR_PROTOCOL, pcb->ctx_cb);
#endif /* PPPOS_SUPPORT */ #endif /* PPPOS_SUPPORT */
} }

View File

@ -384,6 +384,8 @@ pppoe_disc_input(struct netif *netif, struct pbuf *pb)
case PPPOE_TAG_GENERIC_ERR: case PPPOE_TAG_GENERIC_ERR:
err_msg = "GENERIC ERROR"; err_msg = "GENERIC ERROR";
break; break;
default:
break;
} }
if (NULL != err_msg) { if (NULL != err_msg) {
if (len) { if (len) {

View File

@ -203,7 +203,7 @@ static void pppol2tp_input(void *arg, struct udp_pcb *pcb, struct pbuf *p, struc
goto packet_too_short; goto packet_too_short;
} }
inp = p->payload; inp = (u8_t*)p->payload;
GETSHORT(hflags, inp); GETSHORT(hflags, inp);
if (hflags & PPPOL2TP_HEADERFLAG_CONTROL) { if (hflags & PPPOL2TP_HEADERFLAG_CONTROL) {
@ -321,7 +321,7 @@ static void pppol2tp_dispatch_control_packet(pppol2tp_pcb *l2tp, struct ip_addr
u16_t avplen, avpflags, vendorid, attributetype, messagetype=0; u16_t avplen, avpflags, vendorid, attributetype, messagetype=0;
err_t err; err_t err;
#if PPPOL2TP_AUTH_SUPPORT #if PPPOL2TP_AUTH_SUPPORT
md5_context md5_context; md5_context md5_ctx;
u8_t md5_hash[16]; u8_t md5_hash[16];
u8_t challenge_id = 0; u8_t challenge_id = 0;
#endif /* PPPOL2TP_AUTH_SUPPORT */ #endif /* PPPOL2TP_AUTH_SUPPORT */
@ -344,7 +344,7 @@ static void pppol2tp_dispatch_control_packet(pppol2tp_pcb *l2tp, struct ip_addr
return; return;
} }
inp = p->payload; inp = (u8_t*)p->payload;
/* Decode AVPs */ /* Decode AVPs */
while (p->len > 0) { while (p->len > 0) {
if (p->len < sizeof(avpflags) + sizeof(vendorid) + sizeof(attributetype) ) { if (p->len < sizeof(avpflags) + sizeof(vendorid) + sizeof(attributetype) ) {
@ -396,6 +396,8 @@ static void pppol2tp_dispatch_control_packet(pppol2tp_pcb *l2tp, struct ip_addr
*/ */
} }
return; return;
default:
break;
} }
goto nextavp; goto nextavp;
} }
@ -408,8 +410,8 @@ static void pppol2tp_dispatch_control_packet(pppol2tp_pcb *l2tp, struct ip_addr
switch (messagetype) { switch (messagetype) {
/* Start Control Connection Reply */ /* Start Control Connection Reply */
case PPPOL2TP_MESSAGETYPE_SCCRP: case PPPOL2TP_MESSAGETYPE_SCCRP:
switch (attributetype) { switch (attributetype) {
case PPPOL2TP_AVPTYPE_TUNNELID: case PPPOL2TP_AVPTYPE_TUNNELID:
if (avplen != sizeof(l2tp->source_tunnel_id) ) { if (avplen != sizeof(l2tp->source_tunnel_id) ) {
PPPDEBUG(LOG_DEBUG, ("pppol2tp: AVP Assign tunnel ID length check failed\n")); PPPDEBUG(LOG_DEBUG, ("pppol2tp: AVP Assign tunnel ID length check failed\n"));
return; return;
@ -418,7 +420,7 @@ static void pppol2tp_dispatch_control_packet(pppol2tp_pcb *l2tp, struct ip_addr
PPPDEBUG(LOG_DEBUG, ("pppol2tp: Assigned tunnel ID %"U16_F"\n", l2tp->source_tunnel_id)); PPPDEBUG(LOG_DEBUG, ("pppol2tp: Assigned tunnel ID %"U16_F"\n", l2tp->source_tunnel_id));
goto nextavp; goto nextavp;
#if PPPOL2TP_AUTH_SUPPORT #if PPPOL2TP_AUTH_SUPPORT
case PPPOL2TP_AVPTYPE_CHALLENGE: case PPPOL2TP_AVPTYPE_CHALLENGE:
if (avplen == 0) { if (avplen == 0) {
PPPDEBUG(LOG_DEBUG, ("pppol2tp: Challenge length check failed\n")); PPPDEBUG(LOG_DEBUG, ("pppol2tp: Challenge length check failed\n"));
return; return;
@ -429,26 +431,26 @@ static void pppol2tp_dispatch_control_packet(pppol2tp_pcb *l2tp, struct ip_addr
return; return;
} }
/* Generate hash of ID, secret, challenge */ /* Generate hash of ID, secret, challenge */
md5_starts(&md5_context); md5_starts(&md5_ctx);
challenge_id = PPPOL2TP_MESSAGETYPE_SCCCN; challenge_id = PPPOL2TP_MESSAGETYPE_SCCCN;
md5_update(&md5_context, &challenge_id, 1); md5_update(&md5_ctx, &challenge_id, 1);
md5_update(&md5_context, l2tp->secret, l2tp->secret_len); md5_update(&md5_ctx, l2tp->secret, l2tp->secret_len);
md5_update(&md5_context, inp, avplen); md5_update(&md5_ctx, inp, avplen);
md5_finish(&md5_context, l2tp->challenge_hash); md5_finish(&md5_ctx, l2tp->challenge_hash);
l2tp->send_challenge = 1; l2tp->send_challenge = 1;
goto skipavp; goto skipavp;
case PPPOL2TP_AVPTYPE_CHALLENGERESPONSE: case PPPOL2TP_AVPTYPE_CHALLENGERESPONSE:
if (avplen != PPPOL2TP_AVPTYPE_CHALLENGERESPONSE_SIZE) { if (avplen != PPPOL2TP_AVPTYPE_CHALLENGERESPONSE_SIZE) {
PPPDEBUG(LOG_DEBUG, ("pppol2tp: AVP Challenge Response length check failed\n")); PPPDEBUG(LOG_DEBUG, ("pppol2tp: AVP Challenge Response length check failed\n"));
return; return;
} }
/* Generate hash of ID, secret, challenge */ /* Generate hash of ID, secret, challenge */
md5_starts(&md5_context); md5_starts(&md5_ctx);
challenge_id = PPPOL2TP_MESSAGETYPE_SCCRP; challenge_id = PPPOL2TP_MESSAGETYPE_SCCRP;
md5_update(&md5_context, &challenge_id, 1); md5_update(&md5_ctx, &challenge_id, 1);
md5_update(&md5_context, l2tp->secret, l2tp->secret_len); md5_update(&md5_ctx, l2tp->secret, l2tp->secret_len);
md5_update(&md5_context, l2tp->secret_rv, sizeof(l2tp->secret_rv)); md5_update(&md5_ctx, l2tp->secret_rv, sizeof(l2tp->secret_rv));
md5_finish(&md5_context, md5_hash); md5_finish(&md5_ctx, md5_hash);
if ( memcmp(inp, md5_hash, sizeof(md5_hash)) ) { if ( memcmp(inp, md5_hash, sizeof(md5_hash)) ) {
PPPDEBUG(LOG_DEBUG, ("pppol2tp: Received challenge response from peer and secret key do not match\n")); PPPDEBUG(LOG_DEBUG, ("pppol2tp: Received challenge response from peer and secret key do not match\n"));
pppol2tp_abort_connect(l2tp); pppol2tp_abort_connect(l2tp);
@ -456,12 +458,14 @@ static void pppol2tp_dispatch_control_packet(pppol2tp_pcb *l2tp, struct ip_addr
} }
goto skipavp; goto skipavp;
#endif /* PPPOL2TP_AUTH_SUPPORT */ #endif /* PPPOL2TP_AUTH_SUPPORT */
} default:
break; break;
}
break;
/* Incoming Call Reply */ /* Incoming Call Reply */
case PPPOL2TP_MESSAGETYPE_ICRP: case PPPOL2TP_MESSAGETYPE_ICRP:
switch (attributetype) { switch (attributetype) {
case PPPOL2TP_AVPTYPE_SESSIONID: case PPPOL2TP_AVPTYPE_SESSIONID:
if (avplen != sizeof(l2tp->source_session_id) ) { if (avplen != sizeof(l2tp->source_session_id) ) {
PPPDEBUG(LOG_DEBUG, ("pppol2tp: AVP Assign session ID length check failed\n")); PPPDEBUG(LOG_DEBUG, ("pppol2tp: AVP Assign session ID length check failed\n"));
return; return;
@ -469,8 +473,12 @@ static void pppol2tp_dispatch_control_packet(pppol2tp_pcb *l2tp, struct ip_addr
GETSHORT(l2tp->source_session_id, inp); GETSHORT(l2tp->source_session_id, inp);
PPPDEBUG(LOG_DEBUG, ("pppol2tp: Assigned session ID %"U16_F"\n", l2tp->source_session_id)); PPPDEBUG(LOG_DEBUG, ("pppol2tp: Assigned session ID %"U16_F"\n", l2tp->source_session_id));
goto nextavp; goto nextavp;
} default:
break; break;
}
break;
default:
break;
} }
skipavp: skipavp:
@ -991,7 +999,7 @@ err_t pppol2tp_xmit(pppol2tp_pcb *l2tp, struct pbuf *pb) {
return ERR_BUF; return ERR_BUF;
} }
p = pb->payload; p = (u8_t*)pb->payload;
PUTSHORT(PPPOL2TP_HEADERFLAG_DATA_MANDATORY, p); PUTSHORT(PPPOL2TP_HEADERFLAG_DATA_MANDATORY, p);
PUTSHORT(l2tp->source_tunnel_id, p); /* Tunnel Id */ PUTSHORT(l2tp->source_tunnel_id, p); /* Tunnel Id */
PUTSHORT(l2tp->source_session_id, p); /* Session Id */ PUTSHORT(l2tp->source_session_id, p); /* Session Id */

View File

@ -86,7 +86,7 @@ static void upap_lowerdown(ppp_pcb *pcb);
static void upap_input(ppp_pcb *pcb, u_char *inpacket, int l); static void upap_input(ppp_pcb *pcb, u_char *inpacket, int l);
static void upap_protrej(ppp_pcb *pcb); static void upap_protrej(ppp_pcb *pcb);
#if PRINTPKT_SUPPORT #if PRINTPKT_SUPPORT
static int upap_printpkt(u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg); static int upap_printpkt(u_char *p, int plen, void (*printer) (void *, const char *, ...), void *arg);
#endif /* PRINTPKT_SUPPORT */ #endif /* PRINTPKT_SUPPORT */
const struct protent pap_protent = { const struct protent pap_protent = {
@ -126,7 +126,7 @@ static void upap_rauthack(ppp_pcb *pcb, u_char *inp, int id, int len);
static void upap_rauthnak(ppp_pcb *pcb, u_char *inp, int id, int len); static void upap_rauthnak(ppp_pcb *pcb, u_char *inp, int id, int len);
static void upap_sauthreq(ppp_pcb *pcb); static void upap_sauthreq(ppp_pcb *pcb);
#if PPP_SERVER #if PPP_SERVER
static void upap_sresp(ppp_pcb *pcb, u_char code, u_char id, char *msg, int msglen); static void upap_sresp(ppp_pcb *pcb, u_char code, u_char id, const char *msg, int msglen);
#endif /* PPP_SERVER */ #endif /* PPP_SERVER */
@ -363,7 +363,7 @@ static void upap_rauthreq(ppp_pcb *pcb, u_char *inp, int id, int len) {
#endif #endif
char rhostname[256]; char rhostname[256];
int retcode; int retcode;
char *msg; const char *msg;
int msglen; int msglen;
if (pcb->upap.us_serverstate < UPAPSS_LISTEN) if (pcb->upap.us_serverstate < UPAPSS_LISTEN)
@ -546,7 +546,7 @@ static void upap_sauthreq(ppp_pcb *pcb) {
return; return;
} }
outp = p->payload; outp = (u_char*)p->payload;
MAKEHEADER(outp, PPP_PAP); MAKEHEADER(outp, PPP_PAP);
PUTCHAR(UPAP_AUTHREQ, outp); PUTCHAR(UPAP_AUTHREQ, outp);
@ -569,7 +569,7 @@ static void upap_sauthreq(ppp_pcb *pcb) {
/* /*
* upap_sresp - Send a response (ack or nak). * upap_sresp - Send a response (ack or nak).
*/ */
static void upap_sresp(ppp_pcb *pcb, u_char code, u_char id, char *msg, int msglen) { static void upap_sresp(ppp_pcb *pcb, u_char code, u_char id, const char *msg, int msglen) {
struct pbuf *p; struct pbuf *p;
u_char *outp; u_char *outp;
int outlen; int outlen;
@ -583,7 +583,7 @@ static void upap_sresp(ppp_pcb *pcb, u_char code, u_char id, char *msg, int msgl
return; return;
} }
outp = p->payload; outp = (u_char*)p->payload;
MAKEHEADER(outp, PPP_PAP); MAKEHEADER(outp, PPP_PAP);
PUTCHAR(code, outp); PUTCHAR(code, outp);
@ -600,11 +600,11 @@ static void upap_sresp(ppp_pcb *pcb, u_char code, u_char id, char *msg, int msgl
/* /*
* upap_printpkt - print the contents of a PAP packet. * upap_printpkt - print the contents of a PAP packet.
*/ */
static char *upap_codenames[] = { static const char *upap_codenames[] = {
"AuthReq", "AuthAck", "AuthNak" "AuthReq", "AuthAck", "AuthNak"
}; };
static int upap_printpkt(u_char *p, int plen, void (*printer) (void *, char *, ...), void *arg) { static int upap_printpkt(u_char *p, int plen, void (*printer) (void *, const char *, ...), void *arg) {
int code, id, len; int code, id, len;
int mlen, ulen, wlen; int mlen, ulen, wlen;
char *user, *pwd, *msg; char *user, *pwd, *msg;
@ -665,6 +665,8 @@ static int upap_printpkt(u_char *p, int plen, void (*printer) (void *, char *, .
printer(arg, " "); printer(arg, " ");
ppp_print_string(msg, mlen, printer, arg); ppp_print_string(msg, mlen, printer, arg);
break; break;
default:
break;
} }
/* print the rest of the bytes in the packet */ /* print the rest of the bytes in the packet */

View File

@ -69,12 +69,12 @@
extern char *strerror(); extern char *strerror();
#endif #endif
static void ppp_logit(int level, char *fmt, va_list args); static void ppp_logit(int level, const char *fmt, va_list args);
static void ppp_log_write(int level, char *buf); static void ppp_log_write(int level, char *buf);
#if PRINTPKT_SUPPORT #if PRINTPKT_SUPPORT
static void ppp_vslp_printer(void *arg, char *fmt, ...); static void ppp_vslp_printer(void *arg, const char *fmt, ...);
static void ppp_format_packet(u_char *p, int len, static void ppp_format_packet(u_char *p, int len,
void (*printer) (void *, char *, ...), void *arg); void (*printer) (void *, const char *, ...), void *arg);
struct buffer_info { struct buffer_info {
char *ptr; char *ptr;
@ -119,7 +119,7 @@ size_t ppp_strlcat(char *dest, const char *src, size_t len) {
* Doesn't do floating-point formats. * Doesn't do floating-point formats.
* Returns the number of chars put into buf. * Returns the number of chars put into buf.
*/ */
int ppp_slprintf(char *buf, int buflen, char *fmt, ...) { int ppp_slprintf(char *buf, int buflen, const char *fmt, ...) {
va_list args; va_list args;
int n; int n;
@ -134,12 +134,13 @@ int ppp_slprintf(char *buf, int buflen, char *fmt, ...) {
*/ */
#define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0) #define OUTCHAR(c) (buflen > 0? (--buflen, *buf++ = (c)): 0)
int ppp_vslprintf(char *buf, int buflen, char *fmt, va_list args) { int ppp_vslprintf(char *buf, int buflen, const char *fmt, va_list args) {
int c, i, n; int c, i, n;
int width, prec, fillch; int width, prec, fillch;
int base, len, neg, quoted; int base, len, neg, quoted;
unsigned long val = 0; unsigned long val = 0;
char *str, *f, *buf0; const char *f;
char *str, *buf0;
unsigned char *p; unsigned char *p;
char num[32]; char num[32];
#if 0 /* need port */ #if 0 /* need port */
@ -372,6 +373,8 @@ int ppp_vslprintf(char *buf, int buflen, char *fmt, va_list args) {
*--str = 'x'; *--str = 'x';
*--str = '0'; *--str = '0';
break; break;
default:
break;
} }
len = num + sizeof(num) - 1 - str; len = num + sizeof(num) - 1 - str;
} else { } else {
@ -402,7 +405,7 @@ int ppp_vslprintf(char *buf, int buflen, char *fmt, va_list args) {
/* /*
* vslp_printer - used in processing a %P format * vslp_printer - used in processing a %P format
*/ */
static void ppp_vslp_printer(void *arg, char *fmt, ...) { static void ppp_vslp_printer(void *arg, const char *fmt, ...) {
int n; int n;
va_list pvar; va_list pvar;
struct buffer_info *bi; struct buffer_info *bi;
@ -441,7 +444,7 @@ log_packet(p, len, prefix, level)
* calling `printer(arg, format, ...)' to output it. * calling `printer(arg, format, ...)' to output it.
*/ */
static void ppp_format_packet(u_char *p, int len, static void ppp_format_packet(u_char *p, int len,
void (*printer) (void *, char *, ...), void *arg) { void (*printer) (void *, const char *, ...), void *arg) {
int i, n; int i, n;
u_short proto; u_short proto;
const struct protent *protp; const struct protent *protp;
@ -516,7 +519,7 @@ end_pr_log()
* pr_log - printer routine for outputting to log * pr_log - printer routine for outputting to log
*/ */
void void
pr_log (void *arg, char *fmt, ...) pr_log (void *arg, const char *fmt, ...)
{ {
int l, n; int l, n;
va_list pvar; va_list pvar;
@ -566,7 +569,7 @@ pr_log (void *arg, char *fmt, ...)
* ppp_print_string - print a readable representation of a string using * ppp_print_string - print a readable representation of a string using
* printer. * printer.
*/ */
void ppp_print_string(char *p, int len, void (*printer) (void *, char *, ...), void *arg) { void ppp_print_string(char *p, int len, void (*printer) (void *, const char *, ...), void *arg) {
int c; int c;
printer(arg, "\""); printer(arg, "\"");
@ -599,7 +602,7 @@ void ppp_print_string(char *p, int len, void (*printer) (void *, char *, ...), v
/* /*
* ppp_logit - does the hard work for fatal et al. * ppp_logit - does the hard work for fatal et al.
*/ */
static void ppp_logit(int level, char *fmt, va_list args) { static void ppp_logit(int level, const char *fmt, va_list args) {
char buf[1024]; char buf[1024];
ppp_vslprintf(buf, sizeof(buf), fmt, args); ppp_vslprintf(buf, sizeof(buf), fmt, args);
@ -626,7 +629,7 @@ static void ppp_log_write(int level, char *buf) {
/* /*
* ppp_fatal - log an error message and die horribly. * ppp_fatal - log an error message and die horribly.
*/ */
void ppp_fatal(char *fmt, ...) { void ppp_fatal(const char *fmt, ...) {
va_list pvar; va_list pvar;
va_start(pvar, fmt); va_start(pvar, fmt);
@ -642,7 +645,7 @@ void ppp_fatal(char *fmt, ...) {
/* /*
* ppp_error - log an error message. * ppp_error - log an error message.
*/ */
void ppp_error(char *fmt, ...) { void ppp_error(const char *fmt, ...) {
va_list pvar; va_list pvar;
va_start(pvar, fmt); va_start(pvar, fmt);
@ -656,7 +659,7 @@ void ppp_error(char *fmt, ...) {
/* /*
* ppp_warn - log a warning message. * ppp_warn - log a warning message.
*/ */
void ppp_warn(char *fmt, ...) { void ppp_warn(const char *fmt, ...) {
va_list pvar; va_list pvar;
va_start(pvar, fmt); va_start(pvar, fmt);
@ -667,7 +670,7 @@ void ppp_warn(char *fmt, ...) {
/* /*
* ppp_notice - log a notice-level message. * ppp_notice - log a notice-level message.
*/ */
void ppp_notice(char *fmt, ...) { void ppp_notice(const char *fmt, ...) {
va_list pvar; va_list pvar;
va_start(pvar, fmt); va_start(pvar, fmt);
@ -678,7 +681,7 @@ void ppp_notice(char *fmt, ...) {
/* /*
* ppp_info - log an informational message. * ppp_info - log an informational message.
*/ */
void ppp_info(char *fmt, ...) { void ppp_info(const char *fmt, ...) {
va_list pvar; va_list pvar;
va_start(pvar, fmt); va_start(pvar, fmt);
@ -689,7 +692,7 @@ void ppp_info(char *fmt, ...) {
/* /*
* ppp_dbglog - log a debug message. * ppp_dbglog - log a debug message.
*/ */
void ppp_dbglog(char *fmt, ...) { void ppp_dbglog(const char *fmt, ...) {
va_list pvar; va_list pvar;
va_start(pvar, fmt); va_start(pvar, fmt);

View File

@ -95,23 +95,23 @@ vj_compress_init(struct vjcompress *comp)
#define DECODEL(f) { \ #define DECODEL(f) { \
if (*cp == 0) {\ if (*cp == 0) {\
u32_t tmp = ntohl(f) + ((cp[1] << 8) | cp[2]); \ u32_t tmp_ = ntohl(f) + ((cp[1] << 8) | cp[2]); \
(f) = htonl(tmp); \ (f) = htonl(tmp_); \
cp += 3; \ cp += 3; \
} else { \ } else { \
u32_t tmp = ntohl(f) + (u32_t)*cp++; \ u32_t tmp_ = ntohl(f) + (u32_t)*cp++; \
(f) = htonl(tmp); \ (f) = htonl(tmp_); \
} \ } \
} }
#define DECODES(f) { \ #define DECODES(f) { \
if (*cp == 0) {\ if (*cp == 0) {\
u_short tmp = ntohs(f) + (((u_short)cp[1] << 8) | cp[2]); \ u_short tmp_ = ntohs(f) + (((u_short)cp[1] << 8) | cp[2]); \
(f) = htons(tmp); \ (f) = htons(tmp_); \
cp += 3; \ cp += 3; \
} else { \ } else { \
u_short tmp = ntohs(f) + (u_short)*cp++; \ u_short tmp_ = ntohs(f) + (u_short)*cp++; \
(f) = htons(tmp); \ (f) = htons(tmp_); \
} \ } \
} }
@ -342,6 +342,8 @@ vj_compress_tcp(struct vjcompress *comp, struct pbuf *pb)
cp = new_seq; cp = new_seq;
} }
break; break;
default:
break;
} }
deltaS = (u_short)(ntohs(IPH_ID(ip)) - ntohs(IPH_ID(&cs->cs_ip))); deltaS = (u_short)(ntohs(IPH_ID(ip)) - ntohs(IPH_ID(&cs->cs_ip)));
@ -613,7 +615,7 @@ vj_uncompress_tcp(struct pbuf **nb, struct vjcompress *comp)
goto bad; goto bad;
} }
bufptr = n0->payload; bufptr = (u8_t*)n0->payload;
for(q = np; q != NULL; q = q->next) { for(q = np; q != NULL; q = q->next) {
MEMCPY(q->payload, bufptr, q->len); MEMCPY(q->payload, bufptr, q->len);
bufptr += q->len; bufptr += q->len;