more ppp.[ch] cleaning

This commit is contained in:
Sylvain Rochet 2012-06-03 16:24:33 +02:00
parent 05817aa3b9
commit 89d2c2917f
2 changed files with 17 additions and 20 deletions

View File

@ -181,10 +181,6 @@ typedef struct PPPControl_s {
/* Prototypes for procedures local to this file. */ /* Prototypes for procedures local to this file. */
#if PPPOE_SUPPORT
static void pppOverEthernetLinkStatusCB(int pd, int up);
#endif /* PPPOE_SUPPORT */
static void ppp_start(int pd); /** Initiate LCP open request */ static void ppp_start(int pd); /** Initiate LCP open request */
static void ppp_input(void *arg); static void ppp_input(void *arg);
@ -240,7 +236,7 @@ int ppp_init(void) {
memset(&ppp_settings, 0, sizeof(ppp_settings)); memset(&ppp_settings, 0, sizeof(ppp_settings));
ppp_settings.usepeerdns = 1; ppp_settings.usepeerdns = 1;
pppSetAuth(PPPAUTHTYPE_NONE, NULL, NULL); ppp_set_auth(PPPAUTHTYPE_NONE, NULL, NULL);
/* /*
* Initialize magic number generator now so that protocols may * Initialize magic number generator now so that protocols may
@ -257,7 +253,7 @@ int ppp_init(void) {
return 0; return 0;
} }
void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd) { void ppp_set_auth(enum pppAuthType authType, const char *user, const char *passwd) {
/* FIXME: the following may look stupid, but this is just an easy way /* FIXME: the following may look stupid, but this is just an easy way
* to check different auth by changing compile time option * to check different auth by changing compile time option
*/ */
@ -361,11 +357,10 @@ void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd)
} }
#if PPPOE_SUPPORT #if PPPOE_SUPPORT
static void pppOverEthernetLinkStatusCB(int pd, int up); static void ppp_over_ethernet_link_status_cb(int pd, int up);
int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const char *concentrator_name, int ppp_over_ethernet_open(struct netif *ethif, const char *service_name, const char *concentrator_name,
pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx) pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx) {
{
PPPControl *pc; PPPControl *pc;
int pd; int pd;
@ -401,7 +396,7 @@ int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const cha
lcp_allowoptions[pd].neg_pcompression = 0; lcp_allowoptions[pd].neg_pcompression = 0;
lcp_allowoptions[pd].neg_accompression = 0; lcp_allowoptions[pd].neg_accompression = 0;
if(pppoe_create(ethif, pd, pppOverEthernetLinkStatusCB, &pc->pppoe_sc) != ERR_OK) { if(pppoe_create(ethif, pd, ppp_over_ethernet_link_status_cb, &pc->pppoe_sc) != ERR_OK) {
pc->openFlag = 0; pc->openFlag = 0;
return PPPERR_OPEN; return PPPERR_OPEN;
} }
@ -430,16 +425,15 @@ void pppOverEthernetInitFailed(int pd) {
} }
} }
static void pppOverEthernetLinkStatusCB(int pd, int up) { static void ppp_over_ethernet_link_status_cb(int pd, int up) {
if(up) { if(up) {
PPPDEBUG(LOG_INFO, ("pppOverEthernetLinkStatusCB: unit %d: Connecting\n", pd)); PPPDEBUG(LOG_INFO, ("ppp_over_ethernet_link_status_cb: unit %d: Connecting\n", pd));
ppp_start(pd); ppp_start(pd);
} else { } else {
pppOverEthernetInitFailed(pd); pppOverEthernetInitFailed(pd);
} }
} }
#endif #endif /* PPPOE_SUPPORT */
/** Initiate LCP open request */ /** Initiate LCP open request */
@ -450,6 +444,7 @@ static void ppp_start(int pd) {
PPPDEBUG(LOG_DEBUG, ("ppp_start: finished\n")); PPPDEBUG(LOG_DEBUG, ("ppp_start: finished\n"));
} }
/* /*
* Pass the processed input packet to the appropriate handler. * Pass the processed input packet to the appropriate handler.
* This function and all handlers run in the context of the tcpip_thread * This function and all handlers run in the context of the tcpip_thread
@ -1093,7 +1088,7 @@ static int ppp_write_over_ethernet(int pd, const u_char *s, int n) {
#endif /* PPPOE_SUPPORT */ #endif /* PPPOE_SUPPORT */
/* merge a pbuf chain into one pbuf */
struct pbuf * ppp_singlebuf(struct pbuf *p) { struct pbuf * ppp_singlebuf(struct pbuf *p) {
struct pbuf *q, *b; struct pbuf *q, *b;
u_char *pl; u_char *pl;

View File

@ -497,7 +497,7 @@ enum pppAuthType {
/* Initialize the PPP subsystem. */ /* Initialize the PPP subsystem. */
int ppp_init(void); int ppp_init(void);
void pppSetAuth(enum pppAuthType authType, const char *user, const char *passwd); void ppp_set_auth(enum pppAuthType authType, const char *user, const char *passwd);
/* Link status callback function prototype */ /* Link status callback function prototype */
typedef void (*pppLinkStatusCB_fn)(void *ctx, int errCode, void *arg); typedef void (*pppLinkStatusCB_fn)(void *ctx, int errCode, void *arg);
@ -505,13 +505,14 @@ typedef void (*pppLinkStatusCB_fn)(void *ctx, int errCode, void *arg);
/* /*
* Open a new PPP Over Ethernet (PPPOE) connection. * Open a new PPP Over Ethernet (PPPOE) connection.
*/ */
int pppOverEthernetOpen(struct netif *ethif, const char *service_name, const char *concentrator_name, int ppp_over_ethernet_open(struct netif *ethif, const char *service_name, const char *concentrator_name,
pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx); pppLinkStatusCB_fn linkStatusCB, void *linkStatusCtx);
/* ------------------------------------------------------ *
/* --- EVERYTHING BELOW SHOULD BE CONSIDERED PRIVATE ---- */ * --- EVERYTHING BELOW SHOULD BE CONSIDERED PRIVATE ---- *
* ------------------------------------------------------ */
/* PPP flow functions /* PPP flow functions
*/ */
@ -527,6 +528,7 @@ void ppp_input_over_ethernet(int pd, struct pbuf *pb);
/* function called by all PPP subsystems to send packets */ /* function called by all PPP subsystems to send packets */
int ppp_write(int pd, const u_char *s, int n); int ppp_write(int pd, const u_char *s, int n);
/* merge a pbuf chain into one pbuf */
struct pbuf * ppp_singlebuf(struct pbuf *p); struct pbuf * ppp_singlebuf(struct pbuf *p);