moved exit status global variable to ppp_control

This commit is contained in:
Sylvain Rochet 2012-06-09 16:43:12 +02:00
parent 7a57d28db4
commit f94ed922e5
4 changed files with 18 additions and 16 deletions

View File

@ -1113,6 +1113,7 @@ void
auth_withpeer_fail(unit, protocol) auth_withpeer_fail(unit, protocol)
int unit, protocol; int unit, protocol;
{ {
ppp_control *pc = &ppp_control_list[unit];
int errcode = PPPERR_AUTHFAIL; int errcode = PPPERR_AUTHFAIL;
/* /*
* We've failed to authenticate ourselves to our peer. * We've failed to authenticate ourselves to our peer.
@ -1120,7 +1121,7 @@ auth_withpeer_fail(unit, protocol)
* is no point in persisting without any way to get updated * is no point in persisting without any way to get updated
* authentication secrets. * authentication secrets.
*/ */
status = EXIT_AUTH_TOPEER_FAILED; pc->status = EXIT_AUTH_TOPEER_FAILED;
/* /*
* We've failed to authenticate ourselves to our peer. * We've failed to authenticate ourselves to our peer.
@ -1201,12 +1202,13 @@ np_up(unit, proto)
int unit, proto; int unit, proto;
{ {
int tlim; int tlim;
ppp_control *pc = &ppp_control_list[unit];
if (num_np_up == 0) { if (num_np_up == 0) {
/* /*
* At this point we consider that the link has come up successfully. * At this point we consider that the link has come up successfully.
*/ */
status = EXIT_OK; pc->status = EXIT_OK;
new_phase(unit, PHASE_RUNNING); new_phase(unit, PHASE_RUNNING);
#if 0 /* UNUSED */ #if 0 /* UNUSED */
@ -1319,6 +1321,8 @@ static void
check_idle(arg) check_idle(arg)
void *arg; void *arg;
{ {
/* FIXME: fix forced unit 0 */
ppp_control *pc = &ppp_control_list[0];
struct ppp_idle idle; struct ppp_idle idle;
time_t itime; time_t itime;
int tlim; int tlim;
@ -1338,7 +1342,7 @@ check_idle(arg)
if (tlim <= 0) { if (tlim <= 0) {
/* link is idle: shut it down. */ /* link is idle: shut it down. */
notice("Terminating connection due to lack of activity."); notice("Terminating connection due to lack of activity.");
status = EXIT_IDLE_TIMEOUT; pc->status = EXIT_IDLE_TIMEOUT;
lcp_close(0, "Link inactive"); lcp_close(0, "Link inactive");
#if 0 /* UNUSED */ #if 0 /* UNUSED */
need_holdoff = 0; need_holdoff = 0;
@ -1355,8 +1359,10 @@ static void
connect_time_expired(arg) connect_time_expired(arg)
void *arg; void *arg;
{ {
/* FIXME: fix forced unit 0 */
ppp_control *pc = &ppp_control_list[0];
info("Connect time expired"); info("Connect time expired");
status = EXIT_CONNECT_TIME; pc->status = EXIT_CONNECT_TIME;
lcp_close(0, "Connect time expired"); /* Close connection */ lcp_close(0, "Connect time expired"); /* Close connection */
} }

View File

@ -1129,6 +1129,7 @@ lcp_nakci(f, p, len, treat_as_reject)
int len; int len;
int treat_as_reject; int treat_as_reject;
{ {
ppp_control *pc = &ppp_control_list[f->unit];
lcp_options *go = &lcp_gotoptions[f->unit]; lcp_options *go = &lcp_gotoptions[f->unit];
lcp_options *wo = &lcp_wantoptions[f->unit]; lcp_options *wo = &lcp_wantoptions[f->unit];
u_char citype, cichar, *next; u_char citype, cichar, *next;
@ -1555,7 +1556,7 @@ lcp_nakci(f, p, len, treat_as_reject)
if (looped_back) { if (looped_back) {
if (++try.numloops >= lcp_loopbackfail) { if (++try.numloops >= lcp_loopbackfail) {
notice("Serial line is looped back."); notice("Serial line is looped back.");
status = EXIT_LOOPBACK; pc->status = EXIT_LOOPBACK;
lcp_close(f->unit, "Loopback detected"); lcp_close(f->unit, "Loopback detected");
} }
} else } else
@ -2631,10 +2632,11 @@ static
void LcpLinkFailure (f) void LcpLinkFailure (f)
fsm *f; fsm *f;
{ {
ppp_control *pc = &ppp_control_list[f->unit];
if (f->state == OPENED) { if (f->state == OPENED) {
info("No response to %d echo-requests", lcp_echos_pending); info("No response to %d echo-requests", lcp_echos_pending);
notice("Serial link appears to be disconnected."); notice("Serial link appears to be disconnected.");
status = EXIT_PEER_DEAD; pc->status = EXIT_PEER_DEAD;
lcp_close(f->unit, "Peer not responding"); lcp_close(f->unit, "Peer not responding");
} }
} }

View File

@ -145,19 +145,11 @@
#error "PPP_INPROC_OWNTHREAD needs PPP_INPROC_MULTITHREADED==1" #error "PPP_INPROC_OWNTHREAD needs PPP_INPROC_MULTITHREADED==1"
#endif #endif
/*
* Global variables.
*/
/* FIXME: global variables per PPP session */
/* FIXME: clean global variables */
int status; /* exit status for pppd */
/* FIXME: outpacket_buf per PPP session */
/* /*
* Buffers for outgoing packets. This must be accessed only from the appropriate * Buffers for outgoing packets. This must be accessed only from the appropriate
* PPP task so that it doesn't need to be protected to avoid collisions. * PPP task so that it doesn't need to be protected to avoid collisions.
*/ */
/* FIXME: outpacket_buf per PPP session */
u_char outpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for outgoing packet */ u_char outpacket_buf[PPP_MRU+PPP_HDRLEN]; /* buffer for outgoing packet */
#if PPPOS_SUPPORT #if PPPOS_SUPPORT
@ -293,7 +285,6 @@ int ppp_init(void) {
int i; int i;
struct protent *protp; struct protent *protp;
status = EXIT_OK;
#if PPP_STATS_SUPPORT #if PPP_STATS_SUPPORT
link_stats_valid = 0; link_stats_valid = 0;
#endif /* PPP_STATS_SUPPORT */ #endif /* PPP_STATS_SUPPORT */
@ -457,6 +448,7 @@ int ppp_over_serial_open(sio_fd_t fd, ppp_link_status_cb_fn link_status_cb, void
pc->open_flag = 1; pc->open_flag = 1;
pc->fd = fd; pc->fd = fd;
pc->status = EXIT_OK;
new_phase(pd, PHASE_INITIALIZE); new_phase(pd, PHASE_INITIALIZE);
@ -525,6 +517,7 @@ int ppp_over_ethernet_open(struct netif *ethif, const char *service_name, const
memset(pc, 0, sizeof(ppp_control)); memset(pc, 0, sizeof(ppp_control));
pc->open_flag = 1; pc->open_flag = 1;
pc->ethif = ethif; pc->ethif = ethif;
pc->status = EXIT_OK;
new_phase(pd, PHASE_INITIALIZE); new_phase(pd, PHASE_INITIALIZE);

View File

@ -465,6 +465,7 @@ typedef struct ppp_control_s {
ppp_control_rx rx; ppp_control_rx rx;
char open_flag; /* True when in use. */ char open_flag; /* True when in use. */
u8_t phase; /* where the link is at */ u8_t phase; /* where the link is at */
u8_t status; /* exit status */
#if PPPOE_SUPPORT #if PPPOE_SUPPORT
struct netif *ethif; struct netif *ethif;
struct pppoe_softc *pppoe_sc; struct pppoe_softc *pppoe_sc;