PPP: more const and mixed u_char/char types fixes

This commit is contained in:
Sylvain Rochet 2015-09-18 20:11:09 +02:00
parent e8c0ba2a47
commit 83cddd8941
14 changed files with 28 additions and 28 deletions

View File

@ -214,7 +214,7 @@ pppapi_do_pppol2tp_create(struct pppapi_msg_msg *msg)
*/ */
ppp_pcb* ppp_pcb*
pppapi_pppol2tp_create(struct netif *pppif, struct netif *netif, ip_addr_t *ipaddr, u16_t port, pppapi_pppol2tp_create(struct netif *pppif, struct netif *netif, ip_addr_t *ipaddr, u16_t port,
u8_t *secret, u8_t secret_len, const u8_t *secret, u8_t secret_len,
ppp_link_status_cb_fn link_status_cb, void *ctx_cb) ppp_link_status_cb_fn link_status_cb, void *ctx_cb)
{ {
struct pppapi_msg msg; struct pppapi_msg msg;

View File

@ -85,7 +85,7 @@ struct pppapi_msg_msg {
ip_addr_t *ipaddr; ip_addr_t *ipaddr;
u16_t port; u16_t port;
#if PPPOL2TP_AUTH_SUPPORT #if PPPOL2TP_AUTH_SUPPORT
u8_t *secret; const u8_t *secret;
u8_t secret_len; u8_t secret_len;
#endif /* PPPOL2TP_AUTH_SUPPORT */ #endif /* PPPOL2TP_AUTH_SUPPORT */
ppp_link_status_cb_fn link_status_cb; ppp_link_status_cb_fn link_status_cb;
@ -131,7 +131,7 @@ ppp_pcb *pppapi_pppoe_create(struct netif *pppif, struct netif *ethif, const cha
#endif /* PPPOE_SUPPORT */ #endif /* PPPOE_SUPPORT */
#if PPPOL2TP_SUPPORT #if PPPOL2TP_SUPPORT
ppp_pcb *pppapi_pppol2tp_create(struct netif *pppif, struct netif *netif, ip_addr_t *ipaddr, u16_t port, ppp_pcb *pppapi_pppol2tp_create(struct netif *pppif, struct netif *netif, ip_addr_t *ipaddr, u16_t port,
u8_t *secret, u8_t secret_len, const u8_t *secret, u8_t secret_len,
ppp_link_status_cb_fn link_status_cb, void *ctx_cb); ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
#endif /* PPPOL2TP_SUPPORT */ #endif /* PPPOL2TP_SUPPORT */
err_t pppapi_connect(ppp_pcb *pcb, u16_t holdoff); err_t pppapi_connect(ppp_pcb *pcb, u16_t holdoff);

View File

@ -607,7 +607,7 @@ 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 *, const char *, ...), void *arg); /* Format a string for output */ void ppp_print_string(const u_char *p, int len, void (*printer) (void *, const char *, ...), void *arg); /* Format a string for output */
int ppp_slprintf(char *buf, int buflen, const char *fmt, ...); /* sprintf++ */ int ppp_slprintf(char *buf, int buflen, const char *fmt, ...); /* sprintf++ */
int ppp_vslprintf(char *buf, int buflen, const 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 */

View File

@ -169,7 +169,7 @@ struct pppol2tp_pcb_s {
ip_addr_t remote_ip; /* LNS IP Address */ ip_addr_t remote_ip; /* LNS IP Address */
u16_t remote_port; /* LNS port */ u16_t remote_port; /* LNS port */
#if PPPOL2TP_AUTH_SUPPORT #if PPPOL2TP_AUTH_SUPPORT
u8_t *secret; /* Secret string */ const u8_t *secret; /* Secret string */
u8_t secret_len; /* Secret string length */ u8_t secret_len; /* Secret string length */
u8_t secret_rv[16]; /* Random vector */ u8_t secret_rv[16]; /* Random vector */
u8_t challenge_hash[16]; /* Challenge response */ u8_t challenge_hash[16]; /* Challenge response */
@ -194,7 +194,7 @@ struct pppol2tp_pcb_s {
/* Create a new L2TP session. */ /* Create a new L2TP session. */
ppp_pcb *pppol2tp_create(struct netif *pppif, ppp_pcb *pppol2tp_create(struct netif *pppif,
struct netif *netif, ip_addr_t *ipaddr, u16_t port, struct netif *netif, ip_addr_t *ipaddr, u16_t port,
u8_t *secret, u8_t secret_len, const u8_t *secret, u8_t secret_len,
ppp_link_status_cb_fn link_status_cb, void *ctx_cb); ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
#endif /* PPPOL2TP_H_ */ #endif /* PPPOL2TP_H_ */

View File

@ -1628,7 +1628,7 @@ static int ccp_printpkt(const u_char *p, int plen, void (*printer) (void *, cons
case TERMACK: case TERMACK:
case TERMREQ: case TERMREQ:
if (len > 0 && *p >= ' ' && *p < 0x7f) { if (len > 0 && *p >= ' ' && *p < 0x7f) {
ppp_print_string((char *)p, len, printer, arg); ppp_print_string(p, len, printer, arg);
p += len; p += len;
len = 0; len = 0;
} }

View File

@ -626,12 +626,12 @@ static int chap_print_pkt(const unsigned char *p, int plen,
printer(arg, "%.2x", x); printer(arg, "%.2x", x);
} }
printer(arg, ">, name = "); printer(arg, ">, name = ");
ppp_print_string((char *)p, nlen, printer, arg); ppp_print_string(p, nlen, printer, arg);
break; break;
case CHAP_FAILURE: case CHAP_FAILURE:
case CHAP_SUCCESS: case CHAP_SUCCESS:
printer(arg, " "); printer(arg, " ");
ppp_print_string((char *)p, len, printer, arg); ppp_print_string(p, len, printer, arg);
break; break;
default: default:
for (clen = len; clen > 0; --clen) { for (clen = len; clen > 0; --clen) {

View File

@ -1019,7 +1019,7 @@ static void eap_protrej(ppp_pcb *pcb) {
/* /*
* Format and send a regular EAP Response message. * Format and send a regular EAP Response message.
*/ */
static void eap_send_response(ppp_pcb *pcb, u_char id, u_char typenum, u_char *str, int lenstr) { static void eap_send_response(ppp_pcb *pcb, u_char id, u_char typenum, const u_char *str, int lenstr) {
struct pbuf *p; struct pbuf *p;
u_char *outp; u_char *outp;
int msglen; int msglen;
@ -1388,7 +1388,7 @@ static void eap_request(ppp_pcb *pcb, u_char *inp, int id, int len) {
pcb->eap.es_usedpseudo = 2; pcb->eap.es_usedpseudo = 2;
} }
#endif /* USE_SRP */ #endif /* USE_SRP */
eap_send_response(pcb, id, typenum, (u_char*)pcb->eap.es_client.ea_name, eap_send_response(pcb, id, typenum, (const u_char*)pcb->eap.es_client.ea_name,
pcb->eap.es_client.ea_namelen); pcb->eap.es_client.ea_namelen);
break; break;
@ -2173,7 +2173,7 @@ static int eap_printpkt(const u_char *inp, int inlen, void (*printer) (void *, c
case EAPT_NOTIFICATION: case EAPT_NOTIFICATION:
if (len > 0) { if (len > 0) {
printer(arg, " <Message "); printer(arg, " <Message ");
ppp_print_string((char *)inp, len, printer, arg); ppp_print_string(inp, len, printer, arg);
printer(arg, ">"); printer(arg, ">");
INCPTR(len, inp); INCPTR(len, inp);
len = 0; len = 0;
@ -2194,7 +2194,7 @@ static int eap_printpkt(const u_char *inp, int inlen, void (*printer) (void *, c
len -= vallen; len -= vallen;
if (len > 0) { if (len > 0) {
printer(arg, " <Name "); printer(arg, " <Name ");
ppp_print_string((char *)inp, len, printer, arg); ppp_print_string(inp, len, printer, arg);
printer(arg, ">"); printer(arg, ">");
INCPTR(len, inp); INCPTR(len, inp);
len = 0; len = 0;
@ -2217,7 +2217,7 @@ static int eap_printpkt(const u_char *inp, int inlen, void (*printer) (void *, c
goto truncated; goto truncated;
if (vallen > 0) { if (vallen > 0) {
printer(arg, " <Name "); printer(arg, " <Name ");
ppp_print_string((char *)inp, vallen, printer, ppp_print_string(inp, vallen, printer,
arg); arg);
printer(arg, ">"); printer(arg, ">");
} else { } else {
@ -2311,7 +2311,7 @@ static int eap_printpkt(const u_char *inp, int inlen, void (*printer) (void *, c
case EAPT_IDENTITY: case EAPT_IDENTITY:
if (len > 0) { if (len > 0) {
printer(arg, " <Name "); printer(arg, " <Name ");
ppp_print_string((char *)inp, len, printer, arg); ppp_print_string(inp, len, printer, arg);
printer(arg, ">"); printer(arg, ">");
INCPTR(len, inp); INCPTR(len, inp);
len = 0; len = 0;
@ -2346,7 +2346,7 @@ static int eap_printpkt(const u_char *inp, int inlen, void (*printer) (void *, c
len -= vallen; len -= vallen;
if (len > 0) { if (len > 0) {
printer(arg, " <Name "); printer(arg, " <Name ");
ppp_print_string((char *)inp, len, printer, arg); ppp_print_string(inp, len, printer, arg);
printer(arg, ">"); printer(arg, ">");
INCPTR(len, inp); INCPTR(len, inp);
len = 0; len = 0;

View File

@ -2334,7 +2334,7 @@ static int ipcp_printpkt(const u_char *p, int plen,
case TERMREQ: case TERMREQ:
if (len > 0 && *p >= ' ' && *p < 0x7f) { if (len > 0 && *p >= ' ' && *p < 0x7f) {
printer(arg, " "); printer(arg, " ");
ppp_print_string((char *)p, len, printer, arg); ppp_print_string(p, len, printer, arg);
p += len; p += len;
len = 0; len = 0;
} }

View File

@ -1471,7 +1471,7 @@ static int ipv6cp_printpkt(const u_char *p, int plen,
case TERMREQ: case TERMREQ:
if (len > 0 && *p >= ' ' && *p < 0x7f) { if (len > 0 && *p >= ' ' && *p < 0x7f) {
printer(arg, " "); printer(arg, " ");
ppp_print_string((char *)p, len, printer, arg); ppp_print_string(p, len, printer, arg);
p += len; p += len;
len = 0; len = 0;
} }

View File

@ -2573,7 +2573,7 @@ static int lcp_printpkt(const u_char *p, int plen,
case TERMREQ: case TERMREQ:
if (len > 0 && *p >= ' ' && *p < 0x7f) { if (len > 0 && *p >= ' ' && *p < 0x7f) {
printer(arg, " "); printer(arg, " ");
ppp_print_string((char *)p, len, printer, arg); ppp_print_string(p, len, printer, arg);
p += len; p += len;
len = 0; len = 0;
} }
@ -2605,7 +2605,7 @@ static int lcp_printpkt(const u_char *p, int plen,
} }
if (len > 0) { if (len > 0) {
printer(arg, " "); printer(arg, " ");
ppp_print_string((char *)p, len, printer, arg); ppp_print_string(p, len, printer, arg);
p += len; p += len;
len = 0; len = 0;
} }

View File

@ -115,9 +115,9 @@ void
mppe_init(ppp_pcb *pcb, ppp_mppe_state *state, u8_t options) mppe_init(ppp_pcb *pcb, ppp_mppe_state *state, u8_t options)
{ {
#if PPP_DEBUG #if PPP_DEBUG
const u8_t *debugstr = (u8_t*)"mppe_comp_init"; const u8_t *debugstr = (const u8_t*)"mppe_comp_init";
if (&pcb->mppe_decomp == state) { if (&pcb->mppe_decomp == state) {
debugstr = (u8_t*)"mppe_decomp_init"; debugstr = (const u8_t*)"mppe_decomp_init";
} }
#endif /* PPP_DEBUG */ #endif /* PPP_DEBUG */

View File

@ -114,7 +114,7 @@ static const struct link_callbacks pppol2tp_callbacks = {
/* Create a new L2TP session. */ /* Create a new L2TP session. */
ppp_pcb *pppol2tp_create(struct netif *pppif, ppp_pcb *pppol2tp_create(struct netif *pppif,
struct netif *netif, ip_addr_t *ipaddr, u16_t port, struct netif *netif, ip_addr_t *ipaddr, u16_t port,
u8_t *secret, u8_t secret_len, const u8_t *secret, u8_t secret_len,
ppp_link_status_cb_fn link_status_cb, void *ctx_cb) { ppp_link_status_cb_fn link_status_cb, void *ctx_cb) {
ppp_pcb *ppp; ppp_pcb *ppp;
pppol2tp_pcb *l2tp; pppol2tp_pcb *l2tp;

View File

@ -602,7 +602,7 @@ static const char* const upap_codenames[] = {
static int upap_printpkt(const u_char *p, int plen, void (*printer) (void *, const char *, ...), void *arg) { static int upap_printpkt(const 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; const u_char *user, *pwd, *msg;
const u_char *pstart; const u_char *pstart;
if (plen < UPAP_HEADERLEN) if (plen < UPAP_HEADERLEN)
@ -630,8 +630,8 @@ static int upap_printpkt(const u_char *p, int plen, void (*printer) (void *, con
wlen = p[ulen + 1]; wlen = p[ulen + 1];
if (len < ulen + wlen + 2) if (len < ulen + wlen + 2)
break; break;
user = (char *) (p + 1); user = (const u_char *) (p + 1);
pwd = (char *) (p + ulen + 2); pwd = (const u_char *) (p + ulen + 2);
p += ulen + wlen + 2; p += ulen + wlen + 2;
len -= ulen + wlen + 2; len -= ulen + wlen + 2;
printer(arg, " user="); printer(arg, " user=");
@ -654,7 +654,7 @@ static int upap_printpkt(const u_char *p, int plen, void (*printer) (void *, con
mlen = p[0]; mlen = p[0];
if (len < mlen + 1) if (len < mlen + 1)
break; break;
msg = (char *) (p + 1); msg = (const u_char *) (p + 1);
p += mlen + 1; p += mlen + 1;
len -= mlen + 1; len -= mlen + 1;
printer(arg, " "); printer(arg, " ");

View File

@ -569,7 +569,7 @@ pr_log (void *arg, const 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 *, const char *, ...), void *arg) { void ppp_print_string(const u_char *p, int len, void (*printer) (void *, const char *, ...), void *arg) {
int c; int c;
printer(arg, "\""); printer(arg, "\"");