PPP: re-order functions in the common sense API order

Re-order ppp.[ch] functions in the order functions should be called from
user application. Moved create functions, which actually return a PPP
control block before functions needing a PPP control block.
This commit is contained in:
Sylvain Rochet 2015-02-14 22:35:29 +01:00
parent bd29f7168c
commit 7b681bc94a
2 changed files with 64 additions and 64 deletions

View File

@ -504,19 +504,6 @@ struct ppp_pcb_s {
#define PPPAUTHTYPE_EAP 0x08
#define PPPAUTHTYPE_ANY 0xff
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd);
#if PPP_NOTIFY_PHASE
/*
* Set a PPP notify phase callback.
*
* This can be used for example to set a LED pattern depending on the
* current phase of the PPP session.
*/
typedef void (*ppp_notify_phase_cb_fn)(ppp_pcb *pcb, u8_t phase, void *ctx);
void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb);
#endif /* PPP_NOTIFY_PHASE */
/* Link status callback function prototype */
typedef void (*ppp_link_status_cb_fn)(ppp_pcb *pcb, int err_code, void *ctx);
@ -551,6 +538,19 @@ ppp_pcb *ppp_over_l2tp_create(struct netif *pppif, struct netif *netif, ip_addr_
ppp_link_status_cb_fn link_status_cb, void *ctx_cb);
#endif /* PPPOL2TP_SUPPORT */
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd);
#if PPP_NOTIFY_PHASE
/*
* Set a PPP notify phase callback.
*
* This can be used for example to set a LED pattern depending on the
* current phase of the PPP session.
*/
typedef void (*ppp_notify_phase_cb_fn)(ppp_pcb *pcb, u8_t phase, void *ctx);
void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb);
#endif /* PPP_NOTIFY_PHASE */
/*
* Open a PPP connection.
*

View File

@ -225,57 +225,6 @@ static int ppp_write_over_l2tp(ppp_pcb *pcb, struct pbuf *p);
/*** PUBLIC FUNCTION DEFINITIONS ***/
/***********************************/
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd) {
#if PAP_SUPPORT
if (authtype & PPPAUTHTYPE_PAP) {
pcb->settings.refuse_pap = 0;
} else {
pcb->settings.refuse_pap = 1;
}
#endif /* PAP_SUPPORT */
#if CHAP_SUPPORT
if (authtype & PPPAUTHTYPE_CHAP) {
pcb->settings.refuse_chap = 0;
} else {
pcb->settings.refuse_chap = 1;
}
#if MSCHAP_SUPPORT
if (authtype & PPPAUTHTYPE_MSCHAP) {
pcb->settings.refuse_mschap = 0;
pcb->settings.refuse_mschap_v2 = 0;
} else {
pcb->settings.refuse_mschap = 1;
pcb->settings.refuse_mschap_v2 = 1;
}
#endif /* MSCHAP_SUPPORT */
#endif /* CHAP_SUPPORT */
#if EAP_SUPPORT
if (authtype & PPPAUTHTYPE_EAP) {
pcb->settings.refuse_eap = 0;
} else {
pcb->settings.refuse_eap = 1;
}
#endif /* EAP_SUPPORT */
if (user) {
pcb->settings.user = user;
}
if (passwd) {
pcb->settings.passwd = passwd;
}
}
#if PPP_NOTIFY_PHASE
void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb) {
pcb->notify_phase_cb = notify_phase_cb;
notify_phase_cb(pcb, pcb->phase, pcb->ctx_cb);
}
#endif /* PPP_NOTIFY_PHASE */
#if PPPOS_SUPPORT
ppp_pcb *ppp_over_serial_create(struct netif *pppif, sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void *ctx_cb) {
ppp_pcb *pcb;
@ -375,6 +324,57 @@ ppp_pcb *ppp_over_l2tp_create(struct netif *pppif, struct netif *netif, ip_addr_
}
#endif /* PPPOL2TP_SUPPORT */
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd) {
#if PAP_SUPPORT
if (authtype & PPPAUTHTYPE_PAP) {
pcb->settings.refuse_pap = 0;
} else {
pcb->settings.refuse_pap = 1;
}
#endif /* PAP_SUPPORT */
#if CHAP_SUPPORT
if (authtype & PPPAUTHTYPE_CHAP) {
pcb->settings.refuse_chap = 0;
} else {
pcb->settings.refuse_chap = 1;
}
#if MSCHAP_SUPPORT
if (authtype & PPPAUTHTYPE_MSCHAP) {
pcb->settings.refuse_mschap = 0;
pcb->settings.refuse_mschap_v2 = 0;
} else {
pcb->settings.refuse_mschap = 1;
pcb->settings.refuse_mschap_v2 = 1;
}
#endif /* MSCHAP_SUPPORT */
#endif /* CHAP_SUPPORT */
#if EAP_SUPPORT
if (authtype & PPPAUTHTYPE_EAP) {
pcb->settings.refuse_eap = 0;
} else {
pcb->settings.refuse_eap = 1;
}
#endif /* EAP_SUPPORT */
if (user) {
pcb->settings.user = user;
}
if (passwd) {
pcb->settings.passwd = passwd;
}
}
#if PPP_NOTIFY_PHASE
void ppp_set_notify_phase_callback(ppp_pcb *pcb, ppp_notify_phase_cb_fn notify_phase_cb) {
pcb->notify_phase_cb = notify_phase_cb;
notify_phase_cb(pcb, pcb->phase, pcb->ctx_cb);
}
#endif /* PPP_NOTIFY_PHASE */
/*
* Open a PPP connection.
*