mirror of
https://github.com/lwip-tcpip/lwip.git
synced 2024-10-03 21:32:08 +00:00
PPP, CORE, compile out auth support if none of auth protocols are enabled
Added macro PPP_AUTH_SUPPORT, if none of auth protocols are enabled (PAP, CHAP, EAP) we reduce PPP memory usage by compiling out all struct fields and source code used for authentication.
This commit is contained in:
parent
973472c51e
commit
59b659b027
@ -140,6 +140,9 @@
|
||||
#define PPPCTLG_ERRCODE 102 /* Get the error code */
|
||||
#define PPPCTLG_FD 103 /* Get the fd associated with the ppp */
|
||||
|
||||
/* Whether auth support is enabled at all */
|
||||
#define PPP_AUTH_SUPPORT (PAP_SUPPORT || CHAP_SUPPORT || EAP_SUPPORT)
|
||||
|
||||
/************************
|
||||
*** PUBLIC DATA TYPES ***
|
||||
************************/
|
||||
@ -187,12 +190,12 @@ typedef void (*ppp_link_status_cb_fn)(ppp_pcb *pcb, int err_code, void *ctx);
|
||||
*/
|
||||
typedef struct ppp_settings_s {
|
||||
|
||||
#if PPP_SERVER
|
||||
#if PPP_SERVER && PPP_AUTH_SUPPORT
|
||||
unsigned int auth_required : 1; /* Peer is required to authenticate */
|
||||
unsigned int null_login : 1; /* Username of "" and a password of "" are acceptable */
|
||||
#else
|
||||
unsigned int :2; /* 2 bits of padding */
|
||||
#endif /* PPP_SERVER */
|
||||
#endif /* PPP_SERVER && PPP_AUTH_SUPPORT */
|
||||
#if PPP_REMOTENAME
|
||||
unsigned int explicit_remote : 1; /* remote_name specified with remotename opt */
|
||||
#else
|
||||
@ -245,6 +248,7 @@ typedef struct ppp_settings_s {
|
||||
u32_t maxconnect; /* Maximum connect time (seconds) */
|
||||
#endif /* PPP_MAXCONNECT */
|
||||
|
||||
#if PPP_AUTH_SUPPORT
|
||||
/* auth data */
|
||||
const char *user; /* Username for PAP */
|
||||
const char *passwd; /* Password for PAP, secret for CHAP */
|
||||
@ -280,6 +284,8 @@ typedef struct ppp_settings_s {
|
||||
#endif /* PPP_SERVER */
|
||||
#endif /* EAP_SUPPORT */
|
||||
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
|
||||
u8_t fsm_timeout_time; /* Timeout time in seconds */
|
||||
u8_t fsm_max_conf_req_transmits; /* Maximum Configure-Request transmissions */
|
||||
u8_t fsm_max_term_transmits; /* Maximum Terminate-Request transmissions */
|
||||
|
@ -544,6 +544,7 @@ void upper_layers_down(ppp_pcb *pcb); /* take all NCPs down */
|
||||
void link_established(ppp_pcb *pcb); /* the link is up; authenticate now */
|
||||
void start_networks(ppp_pcb *pcb); /* start all the network control protos */
|
||||
void continue_networks(ppp_pcb *pcb); /* start network [ip, etc] control protos */
|
||||
#if PPP_AUTH_SUPPORT
|
||||
#if PPP_SERVER
|
||||
void auth_peer_fail(ppp_pcb *pcb, int protocol);
|
||||
/* peer failed to authenticate itself */
|
||||
@ -554,12 +555,15 @@ void auth_withpeer_fail(ppp_pcb *pcb, int protocol);
|
||||
/* we failed to authenticate ourselves */
|
||||
void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor);
|
||||
/* we successfully authenticated ourselves */
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
void np_up(ppp_pcb *pcb, int proto); /* a network protocol has come up */
|
||||
void np_down(ppp_pcb *pcb, int proto); /* a network protocol has gone down */
|
||||
void np_finished(ppp_pcb *pcb, int proto); /* a network protocol no longer needs link */
|
||||
#if PPP_AUTH_SUPPORT
|
||||
void auth_reset(ppp_pcb *pcb); /* check what secrets we have */
|
||||
int get_secret(ppp_pcb *pcb, const char *client, const char *server, char *secret, int *secret_len, int am_server);
|
||||
/* get "secret" for chap */
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
|
||||
/* Procedures exported from ipcp.c */
|
||||
/* int parse_dotted_ip (char *, u32_t *); */
|
||||
|
@ -725,17 +725,17 @@ void upper_layers_down(ppp_pcb *pcb) {
|
||||
* Proceed to the Dead, Authenticate or Network phase as appropriate.
|
||||
*/
|
||||
void link_established(ppp_pcb *pcb) {
|
||||
#if PPP_AUTH_SUPPORT
|
||||
int auth;
|
||||
#if PPP_SERVER
|
||||
int errcode;
|
||||
lcp_options *wo = &pcb->lcp_wantoptions;
|
||||
lcp_options *go = &pcb->lcp_gotoptions;
|
||||
#endif /* PPP_SERVER */
|
||||
lcp_options *ho = &pcb->lcp_hisoptions;
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
int i;
|
||||
const struct protent *protp;
|
||||
#if PPP_SERVER
|
||||
int errcode;
|
||||
#endif /* PPP_SERVER */
|
||||
|
||||
/*
|
||||
* Tell higher-level protocols that LCP is up.
|
||||
@ -747,6 +747,7 @@ void link_established(ppp_pcb *pcb) {
|
||||
(*protp->lowerup)(pcb);
|
||||
}
|
||||
|
||||
#if PPP_AUTH_SUPPORT
|
||||
#if PPP_SERVER
|
||||
#if PPP_ALLOWED_ADDRS
|
||||
if (!auth_required && noauth_addrs != NULL)
|
||||
@ -838,7 +839,7 @@ void link_established(ppp_pcb *pcb) {
|
||||
pcb->auth_done = 0;
|
||||
|
||||
if (!auth)
|
||||
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
network_phase(pcb);
|
||||
}
|
||||
|
||||
@ -994,6 +995,7 @@ void continue_networks(ppp_pcb *pcb) {
|
||||
lcp_close(pcb, "No network protocols running");
|
||||
}
|
||||
|
||||
#if PPP_AUTH_SUPPORT
|
||||
#if PPP_SERVER
|
||||
/*
|
||||
* The peer has failed to authenticate himself using `protocol'.
|
||||
@ -1156,6 +1158,7 @@ void auth_withpeer_success(ppp_pcb *pcb, int protocol, int prot_flavor) {
|
||||
if ((pcb->auth_pending &= ~bit) == 0)
|
||||
network_phase(pcb);
|
||||
}
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
|
||||
|
||||
/*
|
||||
@ -1469,6 +1472,7 @@ auth_check_options()
|
||||
}
|
||||
#endif /* PPP_OPTIONS */
|
||||
|
||||
#if PPP_AUTH_SUPPORT
|
||||
/*
|
||||
* auth_reset - called when LCP is starting negotiations to recheck
|
||||
* authentication options, i.e. whether we have appropriate secrets
|
||||
@ -1581,6 +1585,7 @@ void auth_reset(ppp_pcb *pcb) {
|
||||
go->neg_eap = 0;
|
||||
#endif
|
||||
}
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
/*
|
||||
@ -1934,6 +1939,7 @@ have_srp_secret(client, server, need_ip, lacks_ipp)
|
||||
}
|
||||
#endif /* UNUSED */
|
||||
|
||||
#if PPP_AUTH_SUPPORT
|
||||
/*
|
||||
* get_secret - open the CHAP secret file and return the secret
|
||||
* for authenticating the given client on the given server.
|
||||
@ -2024,6 +2030,7 @@ int get_secret(ppp_pcb *pcb, const char *client, const char *server, char *secre
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
|
||||
|
||||
#if 0 /* UNUSED */
|
||||
|
@ -665,7 +665,9 @@ static void lcp_resetci(fsm *f) {
|
||||
if (pcb->settings.noendpoint)
|
||||
ao->neg_endpoint = 0;
|
||||
pcb->peer_mru = PPP_MRU;
|
||||
#if PPP_AUTH_SUPPORT
|
||||
auth_reset(pcb);
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
}
|
||||
|
||||
|
||||
|
@ -187,6 +187,8 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u_short prot
|
||||
/***********************************/
|
||||
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd) {
|
||||
|
||||
#if PPP_AUTH_SUPPORT
|
||||
|
||||
#if PAP_SUPPORT
|
||||
if (authtype & PPPAUTHTYPE_PAP) {
|
||||
pcb->settings.refuse_pap = 0;
|
||||
@ -227,6 +229,13 @@ void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *pas
|
||||
if (passwd) {
|
||||
pcb->settings.passwd = passwd;
|
||||
}
|
||||
|
||||
#else /* PPP_AUTH_SUPPORT */
|
||||
LWIP_UNUSED_ARG(pcb);
|
||||
LWIP_UNUSED_ARG(authtype);
|
||||
LWIP_UNUSED_ARG(user);
|
||||
LWIP_UNUSED_ARG(passwd);
|
||||
#endif /* PPP_AUTH_SUPPORT */
|
||||
}
|
||||
|
||||
#if PPP_NOTIFY_PHASE
|
||||
|
Loading…
Reference in New Issue
Block a user