fixed all PPP compilation warnings with -Wall

This commit is contained in:
Sylvain Rochet 2012-06-02 20:46:52 +02:00
parent b4d59fd52d
commit d143acfc76
11 changed files with 105 additions and 83 deletions

View File

@ -751,7 +751,9 @@ link_established(unit)
int unit;
{
int auth;
#if 0 /* UNUSED */
lcp_options *wo = &lcp_wantoptions[unit];
#endif /* UNUSED */
lcp_options *go = &lcp_gotoptions[unit];
lcp_options *ho = &lcp_hisoptions[unit];
int i;
@ -864,7 +866,9 @@ static void
network_phase(unit)
int unit;
{
#if 0 /* UNUSED */
lcp_options *go = &lcp_gotoptions[unit];
#endif /* UNUSED */
#if 0 /* UNUSED */
/* Log calling number. */
@ -919,8 +923,10 @@ void
start_networks(unit)
int unit;
{
#if CCP_SUPPORT || ECP_SUPPORT
int i;
struct protent *protp;
#endif /* CCP_SUPPORT || ECP_SUPPORT */
#if ECP_SUPPORT
int ecp_required;
#endif /* ECP_SUPPORT */
@ -1950,14 +1956,11 @@ get_secret(unit, client, server, secret, secret_len, am_server)
int am_server;
{
int len;
struct wordlist *addrs;
LWIP_UNUSED_ARG(unit);
LWIP_UNUSED_ARG(server);
LWIP_UNUSED_ARG(am_server);
addrs = NULL;
if(!client || !client[0] || strcmp(client, ppp_settings.user)) {
return 0;
}
@ -1993,6 +1996,8 @@ get_secret(unit, client, server, secret, secret_len, am_server)
char *filename;
struct wordlist *addrs, *opts;
char secbuf[MAXWORDLEN];
struct wordlist *addrs;
addrs = NULL;
if (!am_server && ppp_settings.passwd[0] != 0) {
strlcpy(secbuf, ppp_settings.passwd, sizeof(secbuf));

View File

@ -423,7 +423,7 @@ fsm_rconfreq(f, id, inp, len)
{
int code, reject_if_disagree;
printf("fsm_rconfreq() called, f->state = %d\n");
printf("fsm_rconfreq() called, f->state = %d\n", f->state);
switch( f->state ){
case CLOSED:

View File

@ -98,8 +98,10 @@ static bool usepeerdns; /* Ask peer for DNS addrs */
static int ipcp_is_up; /* have called np_up() */
static int ipcp_is_open; /* haven't called np_finished() */
static bool ask_for_local; /* request our address from peer */
#if 0 /* UNUSED */
static char vj_value[8]; /* string form of vj option value */
static char netmask_str[20]; /* string form of netmask value */
#endif /* UNUSED */
/*
* Callbacks for fsm code. (CI = Configuration Information)
@ -138,13 +140,13 @@ static fsm_callbacks ipcp_callbacks = { /* IPCP callback routines */
/*
* Command-line options.
*/
#if PPP_OPTIONS
static int setvjslots __P((char **));
static int setdnsaddr __P((char **));
static int setwinsaddr __P((char **));
static int setnetmask __P((char **));
int setipaddr __P((char *, char **, int));
#if PPP_OPTIONS
static void printipaddr __P((option_t *, void (*)(void *, char *,...),void *));
static option_t ipcp_option_list[] = {
@ -263,12 +265,16 @@ static void ipcp_protrej __P((int));
static int ipcp_printpkt __P((u_char *, int,
void (*) __P((void *, char *, ...)), void *));
#endif /* PRINTPKT_SUPPORT */
#if PPP_OPTIONS
static void ip_check_options __P((void));
#endif /* PPP_OPTIONS */
#if DEMAND_SUPPORT
static int ip_demand_conf __P((int));
static int ip_active_pkt __P((u_char *, int));
#endif /* DEMAND_SUPPORT */
#if 0 /* UNUSED */
static void create_resolv __P((u_int32_t, u_int32_t));
#endif /* UNUSED */
struct protent ipcp_protent = {
PPP_IPCP,
@ -331,7 +337,7 @@ u_int32_t ipaddr;
/*
* Option parsing.
*/
#if PPP_OPTIONS
/*
* setvjslots - set maximum number of connection slots for VJ compression
*/
@ -427,7 +433,6 @@ setwinsaddr(argv)
return (1);
}
#if 0 /* UNUSED */
/*
* setipaddr - Set the IP address
* If doit is 0, the call is to check whether this option is
@ -500,9 +505,7 @@ setipaddr(arg, argv, doit)
return 1;
}
#endif /* UNUSED */
#if PPP_OPTIONS
static void
printipaddr(opt, printer, arg)
option_t *opt;
@ -517,7 +520,6 @@ printipaddr(opt, printer, arg)
if (wo->hisaddr != 0)
printer(arg, "%I", wo->hisaddr);
}
#endif /* PPP_OPTIONS */
/*
* setnetmask - set the netmask to be used on the interface.
@ -582,7 +584,7 @@ parse_dotted_ip(p, vp)
*vp = v;
return p - p0;
}
#endif /* PPP_OPTIONS */
/*
* ipcp_init - Initialize IPCP.
@ -1836,11 +1838,14 @@ ipcp_up(f)
script_setenv("DNS1", ip_ntoa(go->dnsaddr[0]), 0);
if (go->dnsaddr[1])
script_setenv("DNS2", ip_ntoa(go->dnsaddr[1]), 0);
#endif /* UNUSED */
if (usepeerdns && (go->dnsaddr[0] || go->dnsaddr[1])) {
/* FIXME: set here the DNS servers ? */
#if 0 /* UNUSED */
script_setenv("USEPEERDNS", "1", 0);
create_resolv(go->dnsaddr[0], go->dnsaddr[1]);
}
#endif /* UNUSED */
}
/* FIXME: check why it fails, just to know */
#if 0 /* Unused */
@ -2074,6 +2079,7 @@ ipcp_finished(f)
}
#if 0 /* UNUSED */
/*
* create_resolv - create the replacement resolv.conf file
*/
@ -2081,8 +2087,9 @@ static void
create_resolv(peerdns1, peerdns2)
u_int32_t peerdns1, peerdns2;
{
/* FIXME: do we need to set here the DNS servers ? */
}
#endif /* UNUSED */
#if PRINTPKT_SUPPORT
/*

View File

@ -80,7 +80,9 @@ bool lcp_echo_adaptive = 0; /* request echo only if the link was idle */
bool lax_recv = 0; /* accept control chars in asyncmap */
bool noendpoint = 0; /* don't send/accept endpoint discriminator */
#if PPP_OPTIONS
static int noopt __P((char **));
#endif /* PPP_OPTIONS */
#ifdef HAVE_MULTILINK
static int setendpoint __P((char **));
@ -315,6 +317,7 @@ int lcp_loopbackfail = DEFLOOPBACKFAIL;
#define CODENAME(x) ((x) == CONFACK ? "ACK" : \
(x) == CONFNAK ? "NAK" : "REJ")
#if PPP_OPTIONS
/*
* noopt - Disable all options (why?).
*/
@ -327,6 +330,7 @@ noopt(argv)
return (1);
}
#endif /* PPP_OPTIONS */
#ifdef HAVE_MULTILINK
static int
@ -1995,7 +1999,7 @@ lcp_reqci(f, inp, lenp, reject_if_disagree)
PUTSHORT(PPP_CHAP, nakp);
PUTCHAR(CHAP_DIGEST(ao->chap_mdtype), nakp);
} else
#endif CHAP_SUPPORT
#endif /* CHAP_SUPPORT */
#if PAP_SUPPORT
if(1) {
PUTCHAR(CILEN_SHORT, nakp);

View File

@ -182,7 +182,7 @@ void random_bytes(unsigned char *buf, u32_t buf_len) {
u32_t magic() {
u32_t new_rand;
random_bytes((char *)&new_rand, sizeof(new_rand));
random_bytes((unsigned char *)&new_rand, sizeof(new_rand));
return new_rand;
}

View File

@ -10,16 +10,16 @@
#include "lwip/pbuf.h"
#include "lwip/stats.h"
#include "lwip/sys.h"
#if PPPOE_SUPPORT
#include "netif/ppp_oe.h"
#endif /* PPPOE_SUPPORT */
#include "lwip/tcpip.h"
#include "lwip/api.h"
#include "lwip/snmp.h"
#include "ppp.h"
#include "fsm.h"
#include "lcp.h"
#include "ipcp.h"
#include "magic.h"
#if PAP_SUPPORT
#include "upap.h"
@ -37,6 +37,9 @@
#include "ecp.h"
#endif /* EAP_SUPPORT */
#if PPPOE_SUPPORT
#include "netif/ppp_oe.h"
#endif /* PPPOE_SUPPORT */
/*
* Global variables.
@ -176,37 +179,22 @@ typedef struct PPPControl_s {
} PPPControl;
/* Prototypes for procedures local to this file. */
static void pppStart(int pd); /** Initiate LCP open request */
static void ppp_input(void *arg);
static void pppOverEthernetLinkStatusCB(int pd, int up);
static err_t pppifOutputOverEthernet(int pd, struct pbuf *p);
static err_t pppifOutput(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr);
static err_t pppifNetifInit(struct netif *netif);
/******************************/
/*** PUBLIC DATA STRUCTURES ***/
/******************************/
static PPPControl pppControl[NUM_PPP]; /* The PPP interface control blocks. */
struct pbuf * pppSingleBuf(struct pbuf *p) {
struct pbuf *q, *b;
u_char *pl;
if(p->tot_len == p->len) {
return p;
}
q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM);
if(!q) {
PPPDEBUG(LOG_ERR,
("pppSingleBuf: unable to alloc new buf (%d)\n", p->tot_len));
return p; /* live dangerously */
}
for(b = p, pl = q->payload; b != NULL; b = b->next) {
MEMCPY(pl, b->payload, b->len);
pl += b->len;
}
pbuf_free(p);
return q;
}
/** Input helper struct, must be packed since it is stored to pbuf->payload,
* which might be unaligned.
*/
@ -309,7 +297,7 @@ static void ppp_input(void *arg) {
PPPDEBUG(LOG_WARNING, ("pppInput[%d]: Dropping VJ compressed\n", pd));
#else /* PPPOS_SUPPORT && VJ_SUPPORT */
/* No handler for this protocol so drop the packet. */
PPPDEBUG(LOG_INFO, ("pppInput[%d]: drop VJ Comp in %d:%s\n", pd, nb->len, nb->payload));
PPPDEBUG(LOG_INFO, ("pppInput[%d]: drop VJ Comp in %d\n", pd, nb->len));
#endif /* PPPOS_SUPPORT && VJ_SUPPORT */
break;
@ -329,8 +317,8 @@ static void ppp_input(void *arg) {
#else /* PPPOS_SUPPORT && VJ_SUPPORT */
/* No handler for this protocol so drop the packet. */
PPPDEBUG(LOG_INFO,
("pppInput[%d]: drop VJ UnComp in %d:.*H\n",
pd, nb->len, LWIP_MIN(nb->len * 2, 40), nb->payload));
("pppInput[%d]: drop VJ UnComp in %d\n",
pd, nb->len));
#endif /* PPPOS_SUPPORT && VJ_SUPPORT */
break;
@ -531,6 +519,8 @@ int ppp_init(void) {
*/
for (i = 0; (protp = protocols[i]) != NULL; ++i)
(*protp->init)(0);
return 0;
}
void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd) {
@ -688,6 +678,31 @@ int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const cha
return pd;
}
struct pbuf * pppSingleBuf(struct pbuf *p) {
struct pbuf *q, *b;
u_char *pl;
if(p->tot_len == p->len) {
return p;
}
q = pbuf_alloc(PBUF_RAW, p->tot_len, PBUF_RAM);
if(!q) {
PPPDEBUG(LOG_ERR,
("pppSingleBuf: unable to alloc new buf (%d)\n", p->tot_len));
return p; /* live dangerously */
}
for(b = p, pl = q->payload; b != NULL; b = b->next) {
MEMCPY(pl, b->payload, b->len);
pl += b->len;
}
pbuf_free(p);
return q;
}
/* FIXME: maybe we should pass in two arguments pppInputHeader and payload
* this is totally stupid to make room for it and then modify the packet directly
* or it is used in output ? have to find out...
@ -1251,6 +1266,7 @@ void netif_set_mtu(int unit, int mtu) {
*/
int netif_get_mtu(int mtu) {
/* FIXME: get lwIP MTU */
return 1492;
}
/********************************************************************
@ -1555,4 +1571,4 @@ void print_link_stats() {
link_stats_valid = 0;
}
}
#endif PPP_STATS_SUPPORT
#endif /* PPP_STATS_SUPPORT */

View File

@ -12,6 +12,7 @@
#include "lwip/netif.h"
#include "lwip/def.h"
#include "lwip/timers.h"
#include "pppdebug.h"
@ -286,17 +287,6 @@ struct ppp_settings {
struct ppp_settings ppp_settings;
/* FIXME: move all private stuff into a new include */
/*************************
*** PRIVATE FUNCTIONS ***
*************************/
/** Initiate LCP open request */
static void pppStart(int pd);
struct pbuf *pppSingleBuf(struct pbuf *p);
/************************
*** PUBLIC FUNCTIONS ***
@ -333,12 +323,6 @@ enum pppAuthType {
#endif /* CHAP_SUPPORT */
};
struct pbuf * pppSingleBuf(struct pbuf *p);
static void pppStart(int pd);
static void ppp_input(void *arg);
int ppp_init(void);
void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd);
@ -353,16 +337,14 @@ int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const cha
pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx);
/* -- private */
struct pbuf * pppSingleBuf(struct pbuf *p);
void pppInProcOverEthernet(int pd, struct pbuf *pb);
void pppOverEthernetInitFailed(int pd);
static void pppOverEthernetLinkStatusCB(int pd, int up);
static err_t pppifOutputOverEthernet(int pd, struct pbuf *p);
static err_t pppifOutput(struct netif *netif, struct pbuf *pb, ip_addr_t *ipaddr);
u_short pppMTU(int pd);
int pppWriteOverEthernet(int pd, const u_char *s, int n);
@ -379,8 +361,6 @@ int ppp_recv_config(int unit, int mru, u_int32_t accm, int pcomp, int accomp);
int sifaddr(int unit, u_int32_t our_adr, u_int32_t his_adr, u_int32_t net_mask);
int cifaddr(int unit, u_int32_t our_adr, u_int32_t his_adr);
static err_t pppifNetifInit(struct netif *netif);
int sifup(int u);
int sifdown (int u);
@ -531,7 +511,7 @@ int get_secret __P((int, char *, char *, char *, int *, int));
/* get "secret" for chap */
/* Procedures exported from ipcp.c */
int parse_dotted_ip __P((char *, u_int32_t *));
//int parse_dotted_ip __P((char *, u_int32_t *));
/* Procedures exported from demand.c */
#if DEMAND_SUPPORT

View File

@ -645,8 +645,8 @@ pppoe_output(struct pppoe_softc *sc, struct pbuf *pb)
ethhdr = (struct eth_hdr *)pb->payload;
etype = sc->sc_state == PPPOE_STATE_SESSION ? ETHTYPE_PPPOE : ETHTYPE_PPPOEDISC;
ethhdr->type = htons(etype);
MEMCPY(ethhdr->dest.addr, sc->sc_dest.addr, sizeof(ethhdr->dest.addr));
MEMCPY(ethhdr->src.addr, ((struct eth_addr *)sc->sc_ethif->hwaddr)->addr, sizeof(ethhdr->src.addr));
MEMCPY(&ethhdr->dest.addr, &sc->sc_dest.addr, sizeof(ethhdr->dest.addr));
MEMCPY(&ethhdr->src.addr, &sc->sc_ethif->hwaddr, sizeof(ethhdr->src.addr));
PPPDEBUG(LOG_DEBUG, ("pppoe: %c%c%"U16_F" (%x) state=%d, session=0x%x output -> %02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F":%02"X16_F", len=%d\n",
sc->sc_ethif->name[0], sc->sc_ethif->name[1], sc->sc_ethif->num, etype,
@ -957,8 +957,8 @@ pppoe_send_padt(struct netif *outgoing_if, u_int session, const u8_t *dest)
ethhdr = (struct eth_hdr *)pb->payload;
ethhdr->type = PP_HTONS(ETHTYPE_PPPOEDISC);
MEMCPY(ethhdr->dest.addr, dest, sizeof(ethhdr->dest.addr));
MEMCPY(ethhdr->src.addr, ((struct eth_addr *)outgoing_if->hwaddr)->addr, sizeof(ethhdr->src.addr));
MEMCPY(&ethhdr->dest.addr, dest, sizeof(ethhdr->dest.addr));
MEMCPY(&ethhdr->src.addr, &outgoing_if->hwaddr, sizeof(ethhdr->src.addr));
p = (u8_t*)(ethhdr + 1);
PPPOE_ADD_HEADER(p, PPPOE_CODE_PADT, session, 0);

View File

@ -54,7 +54,9 @@
#include "upap.h"
#if 0 /* UNUSED */
static bool hide_password = 1;
#endif /* UNUSED */
#if PPP_OPTIONS
/*
@ -128,7 +130,9 @@ static void upap_rauthreq __P((upap_state *, u_char *, int, int));
static void upap_rauthack __P((upap_state *, u_char *, int, int));
static void upap_rauthnak __P((upap_state *, u_char *, int, int));
static void upap_sauthreq __P((upap_state *));
#if 0 /* UNUSED */
static void upap_sresp __P((upap_state *, int, int, char *, int));
#endif /* UNUSED */
/*
@ -593,7 +597,7 @@ upap_sauthreq(u)
u->us_clientstate = UPAPCS_AUTHREQ;
}
#if 0 /* UNUSED */
/*
* upap_sresp - Send a response (ack or nak).
*/
@ -618,6 +622,7 @@ upap_sresp(u, code, id, msg, msglen)
MEMCPY(outp, msg, msglen);
output(u->us_unit, outpacket_buf, outlen + PPP_HDRLEN);
}
#endif /* UNUSED */
#if PRINTPKT_SUPPORT
/*

View File

@ -102,7 +102,9 @@ typedef struct upap_state {
/*
* Timeouts.
*/
#if 0 /* moved to opt.h */
#define UPAP_DEFTIMEOUT 3 /* Timeout (seconds) for retransmitting req */
#endif /* moved to opt.h */
#define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */
extern upap_state upap[];

View File

@ -70,8 +70,8 @@ extern char *strerror();
static void logit __P((int, char *, va_list));
static void log_write __P((int, char *));
static void vslp_printer __P((void *, char *, ...));
#if PRINTPKT_SUPPORT
static void vslp_printer __P((void *, char *, ...));
static void format_packet __P((u_char *, int, void (*) (void *, char *, ...),
void *));
#endif /* PRINTPKT_SUPPORT */
@ -172,7 +172,9 @@ vslprintf(buf, buflen, fmt, args)
time_t t;
u_int32_t ip;
static char hexchars[] = "0123456789abcdef";
#if PRINTPKT_SUPPORT
struct buffer_info bufinfo;
#endif /* PRINTPKT_SUPPORT */
buf0 = buf;
--buflen;
@ -428,6 +430,7 @@ vslprintf(buf, buflen, fmt, args)
return buf - buf0;
}
#if PRINTPKT_SUPPORT
/*
* vslp_printer - used in processing a %P format
*/
@ -455,6 +458,7 @@ vslp_printer __V((void *arg, char *fmt, ...))
bi->ptr += n;
bi->len -= n;
}
#endif /* PRINTPKT_SUPPORT */
#ifdef unused
/*
@ -662,10 +666,9 @@ logit(level, fmt, args)
char *fmt;
va_list args;
{
int n;
char buf[1024];
n = vslprintf(buf, sizeof(buf), fmt, args);
vslprintf(buf, sizeof(buf), fmt, args);
log_write(level, buf);
}