replaced exit code (pcb->status) with ppp_ioctl()

This commit is contained in:
Sylvain Rochet 2012-06-19 22:00:12 +02:00
parent 2aa9a66c57
commit eadd56a376
5 changed files with 23 additions and 49 deletions

View File

@ -1075,14 +1075,11 @@ void auth_withpeer_fail(ppp_pcb *pcb, int protocol) {
int errcode = PPPERR_AUTHFAIL;
/*
* We've failed to authenticate ourselves to our peer.
*
* Some servers keep sending CHAP challenges, but there
* is no point in persisting without any way to get updated
* authentication secrets.
*/
pcb->status = EXIT_AUTH_TOPEER_FAILED;
/*
* We've failed to authenticate ourselves to our peer.
*
* He'll probably take the link down, and there's not much
* we can do except wait for that.
*/
@ -1161,7 +1158,6 @@ void np_up(ppp_pcb *pcb, int proto) {
/*
* At this point we consider that the link has come up successfully.
*/
pcb->status = EXIT_OK;
new_phase(pcb, PHASE_RUNNING);
#if PPP_IDLETIMELIMIT
@ -1292,9 +1288,10 @@ static void check_idle(void *arg) {
}
#endif /* UNUSED */
if (tlim <= 0) {
int errcode = PPPERR_IDLETIMEOUT;
/* link is idle: shut it down. */
notice("Terminating connection due to lack of activity.");
pcb->status = EXIT_IDLE_TIMEOUT;
ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode);
lcp_close(pcb, "Link inactive");
#if 0 /* UNUSED */
need_holdoff = 0;
@ -1310,9 +1307,10 @@ static void check_idle(void *arg) {
* connect_time_expired - log a message and close the connection.
*/
static void connect_time_expired(void *arg) {
int errcode = PPPERR_CONNECTTIME;
ppp_pcb *pcb = (ppp_pcb*)arg;
info("Connect time expired");
pcb->status = EXIT_CONNECT_TIME;
ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode);
lcp_close(pcb, "Connect time expired"); /* Close connection */
}
#endif /* PPP_MAXCONNECT */

View File

@ -1483,8 +1483,9 @@ static int lcp_nakci(fsm *f, u_char *p, int len, int treat_as_reject) {
if (f->state != OPENED) {
if (looped_back) {
if (++try.numloops >= pcb->lcp_loopbackfail) {
int errcode = PPPERR_LOOPBACK;
notice("Serial line is looped back.");
pcb->status = EXIT_LOOPBACK;
ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode);
lcp_close(f->pcb, "Loopback detected");
}
} else
@ -2547,9 +2548,10 @@ static int lcp_printpkt(u_char *p, int plen,
static void LcpLinkFailure(fsm *f) {
ppp_pcb *pcb = f->pcb;
if (f->state == OPENED) {
int errcode = PPPERR_PEERDEAD;
info("No response to %d echo-requests", pcb->lcp_echos_pending);
notice("Serial link appears to be disconnected.");
pcb->status = EXIT_PEER_DEAD;
ppp_ioctl(pcb, PPPCTLS_ERRCODE, &errcode);
lcp_close(pcb, "Peer not responding");
}
}

View File

@ -238,7 +238,6 @@ ppp_pcb *ppp_new(u8_t num) {
memset(pcb, 0, sizeof(ppp_pcb));
pcb->num = num;
pcb->status = EXIT_OK;
pcb->lcp_loopbackfail = DEFLOOPBACKFAIL;
new_phase(pcb, PHASE_INITIALIZE);

View File

@ -99,15 +99,19 @@ typedef unsigned char bool;
#define PPP_FCSLEN 2 /* octets for FCS */
/* Error codes. */
#define PPPERR_NONE 0 /* No error. */
#define PPPERR_PARAM -1 /* Invalid parameter. */
#define PPPERR_OPEN -2 /* Unable to open PPP session. */
#define PPPERR_DEVICE -3 /* Invalid I/O device for PPP. */
#define PPPERR_ALLOC -4 /* Unable to allocate resources. */
#define PPPERR_USER -5 /* User interrupt. */
#define PPPERR_CONNECT -6 /* Connection lost. */
#define PPPERR_AUTHFAIL -7 /* Failed authentication challenge. */
#define PPPERR_PROTOCOL -8 /* Failed to meet protocol. */
#define PPPERR_NONE 0 /* No error. */
#define PPPERR_PARAM 1 /* Invalid parameter. */
#define PPPERR_OPEN 2 /* Unable to open PPP session. */
#define PPPERR_DEVICE 3 /* Invalid I/O device for PPP. */
#define PPPERR_ALLOC 4 /* Unable to allocate resources. */
#define PPPERR_USER 5 /* User interrupt. */
#define PPPERR_CONNECT 6 /* Connection lost. */
#define PPPERR_AUTHFAIL 7 /* Failed authentication challenge. */
#define PPPERR_PROTOCOL 8 /* Failed to meet protocol. */
#define PPPERR_PEERDEAD 9 /* Connection timeout */
#define PPPERR_IDLETIMEOUT 10 /* Idle Timeout */
#define PPPERR_CONNECTTIME 11 /* Max connect time reached */
#define PPPERR_LOOPBACK 12 /* Loopback detected */
/*
* PPP IOCTL commands.
@ -270,7 +274,6 @@ struct ppp_pcb_s {
ppp_pcb_rx rx;
#endif /* PPPOS_SUPPORT */
u8_t phase; /* where the link is at */
u8_t status; /* exit status */
#if PPPOE_SUPPORT
struct netif *ethif;
struct pppoe_softc *pppoe_sc;

View File

@ -504,34 +504,6 @@ void update_link_stats(int u); /* Get stats at link termination */
PUTCHAR(PPP_UI, p); \
PUTSHORT(t, p); }
/*
* Exit status values.
*/
#define EXIT_OK 0
#define EXIT_FATAL_ERROR 1
#define EXIT_OPTION_ERROR 2
#define EXIT_NOT_ROOT 3
#define EXIT_NO_KERNEL_SUPPORT 4
#define EXIT_USER_REQUEST 5
#define EXIT_LOCK_FAILED 6
#define EXIT_OPEN_FAILED 7
#define EXIT_CONNECT_FAILED 8
#define EXIT_PTYCMD_FAILED 9
#define EXIT_NEGOTIATION_FAILED 10
#define EXIT_PEER_AUTH_FAILED 11
#define EXIT_IDLE_TIMEOUT 12
#define EXIT_CONNECT_TIME 13
#define EXIT_CALLBACK 14
#define EXIT_PEER_DEAD 15
#define EXIT_HANGUP 16
#define EXIT_LOOPBACK 17
#define EXIT_INIT_FAILED 18
#define EXIT_AUTH_TOPEER_FAILED 19
#ifdef MAXOCTETS
#define EXIT_TRAFFIC_LIMIT 20
#endif
#define EXIT_CNID_AUTH_FAILED 21
/* Procedures exported from auth.c */
void link_required(ppp_pcb *pcb); /* we are starting to use the link */
void link_terminated(ppp_pcb *pcb); /* we are finished with the link */