From 83cddd8941da4a8a150a2b14eae6f738c902eca1 Mon Sep 17 00:00:00 2001 From: Sylvain Rochet Date: Fri, 18 Sep 2015 20:11:09 +0200 Subject: [PATCH] PPP: more const and mixed u_char/char types fixes --- src/api/pppapi.c | 2 +- src/include/lwip/pppapi.h | 4 ++-- src/include/netif/ppp/ppp_impl.h | 2 +- src/include/netif/ppp/pppol2tp.h | 4 ++-- src/netif/ppp/ccp.c | 2 +- src/netif/ppp/chap-new.c | 4 ++-- src/netif/ppp/eap.c | 14 +++++++------- src/netif/ppp/ipcp.c | 2 +- src/netif/ppp/ipv6cp.c | 2 +- src/netif/ppp/lcp.c | 4 ++-- src/netif/ppp/mppe.c | 4 ++-- src/netif/ppp/pppol2tp.c | 2 +- src/netif/ppp/upap.c | 8 ++++---- src/netif/ppp/utils.c | 2 +- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/src/api/pppapi.c b/src/api/pppapi.c index e1122d77..b2a9a88c 100644 --- a/src/api/pppapi.c +++ b/src/api/pppapi.c @@ -214,7 +214,7 @@ pppapi_do_pppol2tp_create(struct pppapi_msg_msg *msg) */ 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) { struct pppapi_msg msg; diff --git a/src/include/lwip/pppapi.h b/src/include/lwip/pppapi.h index 28c8a5fd..6626dbe9 100644 --- a/src/include/lwip/pppapi.h +++ b/src/include/lwip/pppapi.h @@ -85,7 +85,7 @@ struct pppapi_msg_msg { ip_addr_t *ipaddr; u16_t port; #if PPPOL2TP_AUTH_SUPPORT - u8_t *secret; + const u8_t *secret; u8_t secret_len; #endif /* PPPOL2TP_AUTH_SUPPORT */ 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 */ #if PPPOL2TP_SUPPORT 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); #endif /* PPPOL2TP_SUPPORT */ err_t pppapi_connect(ppp_pcb *pcb, u16_t holdoff); diff --git a/src/include/netif/ppp/ppp_impl.h b/src/include/netif/ppp/ppp_impl.h index 47423bcb..82e6299c 100644 --- a/src/include/netif/ppp/ppp_impl.h +++ b/src/include/netif/ppp/ppp_impl.h @@ -607,7 +607,7 @@ int str_to_epdisc (struct epdisc *, char *); /* endpt disc. from str */ #endif /* 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_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 */ diff --git a/src/include/netif/ppp/pppol2tp.h b/src/include/netif/ppp/pppol2tp.h index df57c189..097b4d18 100644 --- a/src/include/netif/ppp/pppol2tp.h +++ b/src/include/netif/ppp/pppol2tp.h @@ -169,7 +169,7 @@ struct pppol2tp_pcb_s { ip_addr_t remote_ip; /* LNS IP Address */ u16_t remote_port; /* LNS port */ #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_rv[16]; /* Random vector */ u8_t challenge_hash[16]; /* Challenge response */ @@ -194,7 +194,7 @@ struct pppol2tp_pcb_s { /* Create a new L2TP session. */ ppp_pcb *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); #endif /* PPPOL2TP_H_ */ diff --git a/src/netif/ppp/ccp.c b/src/netif/ppp/ccp.c index 935e1760..873cd68a 100644 --- a/src/netif/ppp/ccp.c +++ b/src/netif/ppp/ccp.c @@ -1628,7 +1628,7 @@ static int ccp_printpkt(const u_char *p, int plen, void (*printer) (void *, cons case TERMACK: case TERMREQ: if (len > 0 && *p >= ' ' && *p < 0x7f) { - ppp_print_string((char *)p, len, printer, arg); + ppp_print_string(p, len, printer, arg); p += len; len = 0; } diff --git a/src/netif/ppp/chap-new.c b/src/netif/ppp/chap-new.c index 4661b981..f0753976 100644 --- a/src/netif/ppp/chap-new.c +++ b/src/netif/ppp/chap-new.c @@ -626,12 +626,12 @@ static int chap_print_pkt(const unsigned char *p, int plen, printer(arg, "%.2x", x); } printer(arg, ">, name = "); - ppp_print_string((char *)p, nlen, printer, arg); + ppp_print_string(p, nlen, printer, arg); break; case CHAP_FAILURE: case CHAP_SUCCESS: printer(arg, " "); - ppp_print_string((char *)p, len, printer, arg); + ppp_print_string(p, len, printer, arg); break; default: for (clen = len; clen > 0; --clen) { diff --git a/src/netif/ppp/eap.c b/src/netif/ppp/eap.c index 717c8dff..58820652 100644 --- a/src/netif/ppp/eap.c +++ b/src/netif/ppp/eap.c @@ -1019,7 +1019,7 @@ static void eap_protrej(ppp_pcb *pcb) { /* * 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; u_char *outp; 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; } #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); break; @@ -2173,7 +2173,7 @@ static int eap_printpkt(const u_char *inp, int inlen, void (*printer) (void *, c case EAPT_NOTIFICATION: if (len > 0) { printer(arg, " "); INCPTR(len, inp); len = 0; @@ -2194,7 +2194,7 @@ static int eap_printpkt(const u_char *inp, int inlen, void (*printer) (void *, c len -= vallen; if (len > 0) { printer(arg, " "); INCPTR(len, inp); len = 0; @@ -2217,7 +2217,7 @@ static int eap_printpkt(const u_char *inp, int inlen, void (*printer) (void *, c goto truncated; if (vallen > 0) { printer(arg, " "); } else { @@ -2311,7 +2311,7 @@ static int eap_printpkt(const u_char *inp, int inlen, void (*printer) (void *, c case EAPT_IDENTITY: if (len > 0) { printer(arg, " "); INCPTR(len, inp); len = 0; @@ -2346,7 +2346,7 @@ static int eap_printpkt(const u_char *inp, int inlen, void (*printer) (void *, c len -= vallen; if (len > 0) { printer(arg, " "); INCPTR(len, inp); len = 0; diff --git a/src/netif/ppp/ipcp.c b/src/netif/ppp/ipcp.c index d19561ad..5dc65f6f 100644 --- a/src/netif/ppp/ipcp.c +++ b/src/netif/ppp/ipcp.c @@ -2334,7 +2334,7 @@ static int ipcp_printpkt(const u_char *p, int plen, case TERMREQ: if (len > 0 && *p >= ' ' && *p < 0x7f) { printer(arg, " "); - ppp_print_string((char *)p, len, printer, arg); + ppp_print_string(p, len, printer, arg); p += len; len = 0; } diff --git a/src/netif/ppp/ipv6cp.c b/src/netif/ppp/ipv6cp.c index 48ad7271..71ac9d7d 100644 --- a/src/netif/ppp/ipv6cp.c +++ b/src/netif/ppp/ipv6cp.c @@ -1471,7 +1471,7 @@ static int ipv6cp_printpkt(const u_char *p, int plen, case TERMREQ: if (len > 0 && *p >= ' ' && *p < 0x7f) { printer(arg, " "); - ppp_print_string((char *)p, len, printer, arg); + ppp_print_string(p, len, printer, arg); p += len; len = 0; } diff --git a/src/netif/ppp/lcp.c b/src/netif/ppp/lcp.c index 572fa030..ab1196c2 100644 --- a/src/netif/ppp/lcp.c +++ b/src/netif/ppp/lcp.c @@ -2573,7 +2573,7 @@ static int lcp_printpkt(const u_char *p, int plen, case TERMREQ: if (len > 0 && *p >= ' ' && *p < 0x7f) { printer(arg, " "); - ppp_print_string((char *)p, len, printer, arg); + ppp_print_string(p, len, printer, arg); p += len; len = 0; } @@ -2605,7 +2605,7 @@ static int lcp_printpkt(const u_char *p, int plen, } if (len > 0) { printer(arg, " "); - ppp_print_string((char *)p, len, printer, arg); + ppp_print_string(p, len, printer, arg); p += len; len = 0; } diff --git a/src/netif/ppp/mppe.c b/src/netif/ppp/mppe.c index 67ca8e4f..67b53e85 100644 --- a/src/netif/ppp/mppe.c +++ b/src/netif/ppp/mppe.c @@ -115,9 +115,9 @@ void mppe_init(ppp_pcb *pcb, ppp_mppe_state *state, u8_t options) { #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) { - debugstr = (u8_t*)"mppe_decomp_init"; + debugstr = (const u8_t*)"mppe_decomp_init"; } #endif /* PPP_DEBUG */ diff --git a/src/netif/ppp/pppol2tp.c b/src/netif/ppp/pppol2tp.c index c9defe11..ec31bc77 100644 --- a/src/netif/ppp/pppol2tp.c +++ b/src/netif/ppp/pppol2tp.c @@ -114,7 +114,7 @@ static const struct link_callbacks pppol2tp_callbacks = { /* Create a new L2TP session. */ ppp_pcb *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_pcb *ppp; pppol2tp_pcb *l2tp; diff --git a/src/netif/ppp/upap.c b/src/netif/ppp/upap.c index f1fece3b..470303a2 100644 --- a/src/netif/ppp/upap.c +++ b/src/netif/ppp/upap.c @@ -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) { int code, id, len; int mlen, ulen, wlen; - char *user, *pwd, *msg; + const u_char *user, *pwd, *msg; const u_char *pstart; 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]; if (len < ulen + wlen + 2) break; - user = (char *) (p + 1); - pwd = (char *) (p + ulen + 2); + user = (const u_char *) (p + 1); + pwd = (const u_char *) (p + ulen + 2); p += ulen + wlen + 2; len -= ulen + wlen + 2; printer(arg, " user="); @@ -654,7 +654,7 @@ static int upap_printpkt(const u_char *p, int plen, void (*printer) (void *, con mlen = p[0]; if (len < mlen + 1) break; - msg = (char *) (p + 1); + msg = (const u_char *) (p + 1); p += mlen + 1; len -= mlen + 1; printer(arg, " "); diff --git a/src/netif/ppp/utils.c b/src/netif/ppp/utils.c index cf68e34d..c1d797ae 100644 --- a/src/netif/ppp/utils.c +++ b/src/netif/ppp/utils.c @@ -569,7 +569,7 @@ pr_log (void *arg, const char *fmt, ...) * ppp_print_string - print a readable representation of a string using * 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; printer(arg, "\"");