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)
int unit, protocol;
{
ppp_control *pc = &ppp_control_list[unit];
int errcode = PPPERR_AUTHFAIL;
/*
* 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
* authentication secrets.
*/
status = EXIT_AUTH_TOPEER_FAILED;
pc->status = EXIT_AUTH_TOPEER_FAILED;
/*
* We've failed to authenticate ourselves to our peer.
@ -1201,12 +1202,13 @@ np_up(unit, proto)
int unit, proto;
{
int tlim;
ppp_control *pc = &ppp_control_list[unit];
if (num_np_up == 0) {
/*
* At this point we consider that the link has come up successfully.
*/
status = EXIT_OK;
pc->status = EXIT_OK;
new_phase(unit, PHASE_RUNNING);
#if 0 /* UNUSED */
@ -1319,6 +1321,8 @@ static void
check_idle(arg)
void *arg;
{
/* FIXME: fix forced unit 0 */
ppp_control *pc = &ppp_control_list[0];
struct ppp_idle idle;
time_t itime;
int tlim;
@ -1338,7 +1342,7 @@ check_idle(arg)
if (tlim <= 0) {
/* link is idle: shut it down. */
notice("Terminating connection due to lack of activity.");
status = EXIT_IDLE_TIMEOUT;
pc->status = EXIT_IDLE_TIMEOUT;
lcp_close(0, "Link inactive");
#if 0 /* UNUSED */
need_holdoff = 0;
@ -1355,8 +1359,10 @@ static void
connect_time_expired(arg)
void *arg;
{
/* FIXME: fix forced unit 0 */
ppp_control *pc = &ppp_control_list[0];
info("Connect time expired");
status = EXIT_CONNECT_TIME;
pc->status = EXIT_CONNECT_TIME;
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 treat_as_reject;
{
ppp_control *pc = &ppp_control_list[f->unit];
lcp_options *go = &lcp_gotoptions[f->unit];
lcp_options *wo = &lcp_wantoptions[f->unit];
u_char citype, cichar, *next;
@ -1555,7 +1556,7 @@ lcp_nakci(f, p, len, treat_as_reject)
if (looped_back) {
if (++try.numloops >= lcp_loopbackfail) {
notice("Serial line is looped back.");
status = EXIT_LOOPBACK;
pc->status = EXIT_LOOPBACK;
lcp_close(f->unit, "Loopback detected");
}
} else
@ -2631,10 +2632,11 @@ static
void LcpLinkFailure (f)
fsm *f;
{
ppp_control *pc = &ppp_control_list[f->unit];
if (f->state == OPENED) {
info("No response to %d echo-requests", lcp_echos_pending);
notice("Serial link appears to be disconnected.");
status = EXIT_PEER_DEAD;
pc->status = EXIT_PEER_DEAD;
lcp_close(f->unit, "Peer not responding");
}
}

View File

@ -145,19 +145,11 @@
#error "PPP_INPROC_OWNTHREAD needs PPP_INPROC_MULTITHREADED==1"
#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
* 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 */
#if PPPOS_SUPPORT
@ -293,7 +285,6 @@ int ppp_init(void) {
int i;
struct protent *protp;
status = EXIT_OK;
#if PPP_STATS_SUPPORT
link_stats_valid = 0;
#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->fd = fd;
pc->status = EXIT_OK;
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));
pc->open_flag = 1;
pc->ethif = ethif;
pc->status = EXIT_OK;
new_phase(pd, PHASE_INITIALIZE);

View File

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