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:
Sylvain Rochet
2015-02-21 19:32:38 +01:00
parent 973472c51e
commit 59b659b027
5 changed files with 34 additions and 6 deletions

View File

@@ -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 */

View File

@@ -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 *); */