Ticket #371: pr371.diff

File pr371.diff, 15.6 KB (added by Eric Norum, on 12/03/06 at 13:31:13)

pr371.diff

  • c/src/libnetworking/pppd//auth.c

    RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/auth.c,v
    retrieving revision 1.5
    diff -u -r1.5 auth.c
     
    249249link_terminated(unit)
    250250    int unit;
    251251{
    252     if (phase == PHASE_DEAD)
     252    if (pppd_phase == PHASE_DEAD)
    253253        return;
    254254    if (pap_logout_hook) {
    255255        pap_logout_hook();
     
    283283    }
    284284    num_np_open = 0;
    285285    num_np_up = 0;
    286     if (phase != PHASE_DEAD)
     286    if (pppd_phase != PHASE_DEAD)
    287287        new_phase(PHASE_TERMINATE);
    288288}
    289289
     
    323323        } else if (!wo->neg_upap || !null_login(unit)) {
    324324            warn("peer refused to authenticate: terminating link");
    325325            lcp_close(unit, "peer refused to authenticate");
    326             status = EXIT_PEER_AUTH_FAILED;
     326            pppd_status = EXIT_PEER_AUTH_FAILED;
    327327            return;
    328328        }
    329329    }
     
    425425     * Authentication failure: take the link down
    426426     */
    427427    lcp_close(unit, "Authentication failed");
    428     status = EXIT_PEER_AUTH_FAILED;
     428    pppd_status = EXIT_PEER_AUTH_FAILED;
    429429}
    430430
    431431/*
     
    483483     * authentication secrets.
    484484     */
    485485    lcp_close(unit, "Failed to authenticate ourselves to peer");
    486     status = EXIT_AUTH_TOPEER_FAILED;
     486    pppd_status = EXIT_AUTH_TOPEER_FAILED;
    487487}
    488488
    489489/*
     
    531531        /*
    532532         * At this point we consider that the link has come up successfully.
    533533         */
    534         status = EXIT_OK;
     534        pppd_status = EXIT_OK;
    535535        unsuccess = 0;
    536536        new_phase(PHASE_RUNNING);
    537537
     
    603603        notice("Terminating connection due to lack of activity.");
    604604        lcp_close(0, "Link inactive");
    605605        need_holdoff = 0;
    606         status = EXIT_IDLE_TIMEOUT;
     606        pppd_status = EXIT_IDLE_TIMEOUT;
    607607    } else {
    608608        TIMEOUT(check_idle, NULL, tlim);
    609609    }
     
    618618{
    619619    info("Connect time expired");
    620620    lcp_close(0, "Connect time expired");       /* Close connection */
    621     status = EXIT_CONNECT_TIME;
     621    pppd_status = EXIT_CONNECT_TIME;
    622622}
    623623
    624624/*
  • c/src/libnetworking/pppd//chat.c

    RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/chat.c,v
    retrieving revision 1.7
    diff -u -r1.7 chat.c
     
    140140#endif
    141141/*************** Micro getopt() *********************************************/
    142142
    143 char *program_name;
    144 
    145143#define MAX_ABORTS              16
    146144#define MAX_REPORTS             16
    147145#define DEFAULT_CHAT_TIMEOUT    45
    148146#define MAX_TIMEOUTS            10
    149147
    150 int echo             = 0;
    151 int quiet            = 0;
    152 int report           = 0;
    153 int use_env          = 0;
    154 int exit_code        = 0;
    155 char *report_file    = (char *) 0;
    156 char *chat_file      = (char *) 0;
    157 char *phone_num      = (char *) 0;
    158 char *phone_num2     = (char *) 0;
     148static int echo             = 0;
     149static int quiet            = 0;
     150static int use_env          = 0;
     151static int exit_code        = 0;
     152static char *phone_num      = (char *) 0;
     153static char *phone_num2     = (char *) 0;
    159154static int ttyfd;
    160155static int timeout   = DEFAULT_CHAT_TIMEOUT;
    161156
  • c/src/libnetworking/pppd//demand.c

    RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/demand.c,v
    retrieving revision 1.3
    diff -u -r1.3 demand.c
     
    4545
    4646static const char rcsid[] = RCSID;
    4747
    48 char *frame;
    49 int framelen;
    50 int framemax;
    51 int escape_flag;
    52 int flush_flag;
    53 int fcs;
     48static char *frame;
     49static int framelen;
     50static int framemax;
     51static int escape_flag;
     52static int flush_flag;
     53static int fcs;
    5454
    5555struct packet {
    5656    int length;
  • c/src/libnetworking/pppd//fsm.c

    RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/fsm.c,v
    retrieving revision 1.6
    diff -u -r1.6 fsm.c
     
    4545
    4646#define PROTO_NAME(f)   ((f)->callbacks->proto_name)
    4747
    48 int peer_mru[NUM_PPP];
     48static int peer_mru[NUM_PPP];
    4949
    5050
    5151/*
  • c/src/libnetworking/pppd//lcp.c

    RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/lcp.c,v
    retrieving revision 1.3
    diff -u -r1.3 lcp.c
     
    3838/*
    3939 * LCP-related command-line options.
    4040 */
    41 int     lcp_echo_interval = 0;  /* Interval between LCP echo-requests */
    42 int     lcp_echo_fails = 0;     /* Tolerance to unanswered echo-requests */
    43 bool    lax_recv = 0;           /* accept control chars in asyncmap */
     41static int      lcp_echo_interval = 0;  /* Interval between LCP echo-requests */
     42static int      lcp_echo_fails = 0;     /* Tolerance to unanswered echo-requests */
     43static bool     lax_recv = 0;           /* accept control chars in asyncmap */
    4444
    4545static int setescape __P((char **));
    4646
     
    335335{
    336336    fsm *f = &lcp_fsm[unit];
    337337
    338     if (phase != PHASE_DEAD)
     338    if (pppd_phase != PHASE_DEAD)
    339339        new_phase(PHASE_TERMINATE);
    340340    if (f->state == STOPPED && f->flags & (OPT_PASSIVE|OPT_SILENT)) {
    341341        /*
     
    10631063            if (++try.numloops >= lcp_loopbackfail) {
    10641064                notice("Serial line is looped back.");
    10651065                lcp_close(f->unit, "Loopback detected");
    1066                 status = EXIT_LOOPBACK;
     1066                pppd_status = EXIT_LOOPBACK;
    10671067            }
    10681068        } else
    10691069            try.numloops = 0;
     
    18151815        info("No response to %d echo-requests", lcp_echos_pending);
    18161816        notice("Serial link appears to be disconnected.");
    18171817        lcp_close(f->unit, "Peer not responding");
    1818         status = EXIT_PEER_DEAD;
     1818        pppd_status = EXIT_PEER_DEAD;
    18191819    }
    18201820}
    18211821
  • c/src/libnetworking/pppd//options.c

    RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/options.c,v
    retrieving revision 1.4
    diff -u -r1.4 options.c
     
    623623
    624624    if ((opt->flags & OPT_PREPASS) == 0 && prepass)
    625625        return 1;
    626     if ((opt->flags & OPT_INITONLY) && phase != PHASE_INITIALIZE) {
     626    if ((opt->flags & OPT_INITONLY) && pppd_phase != PHASE_INITIALIZE) {
    627627        option_error("it's too late to use the %s option", opt->name);
    628628        return 0;
    629629    }
     
    777777static void
    778778usage()
    779779{
    780     if (phase == PHASE_INITIALIZE)
     780    if (pppd_phase == PHASE_INITIALIZE)
    781781        fprintf(stderr, usage_string, VERSION, PATCHLEVEL, IMPLEMENTATION,
    782                 progname);
     782                "rtems_pppd");
    783783}
    784784
    785785/*
    786786 * option_error - print a message about an error in an option.
    787787 * The message is logged, and also sent to
    788  * stderr if phase == PHASE_INITIALIZE.
     788 * stderr if pppd_phase == PHASE_INITIALIZE.
    789789 */
    790790void
    791791option_error __V((char *fmt, ...))
     
    13221322        return -1;
    13231323    }
    13241324
    1325     if (phase != PHASE_INITIALIZE) {
     1325    if (pppd_phase != PHASE_INITIALIZE) {
    13261326        option_error("device name cannot be changed after initialization");
    13271327        return -1;
    13281328    } else if (devnam_fixed) {
  • c/src/libnetworking/pppd//pppd.h

    RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/pppd.h,v
    retrieving revision 1.7
    diff -u -r1.7 pppd.h
     
    137137 * Global variables.
    138138 */
    139139
    140 extern int      kill_link;      /* Signal to terminate processing loop */
     140extern int      pppd_kill_link; /* Signal to terminate processing loop */
    141141extern int      hungup;         /* Physical layer has disconnected */
    142142extern int      pppifunit;      /* Interface unit number */
    143143extern char     ifname[];       /* Interface name */
    144144extern int      ttyfd;          /* Serial device file descriptor */
    145145extern char     hostname[];     /* Our hostname */
    146146extern u_char   outpacket_buf[]; /* Buffer for outgoing packets */
    147 extern int      phase;          /* Current state of link - see values below */
     147extern int      pppd_phase;             /* Current state of link - see values below */
    148148extern int      baud_rate;      /* Current link speed in bits/sec */
    149 extern char     *progname;      /* Name of this program */
    150149extern int      redirect_stderr;/* Connector's stderr should go to file */
    151150extern char     peer_authname[];/* Authenticated name of peer */
    152151extern int      privileged;     /* We were run by real-uid root */
     
    159158extern int      using_pty;      /* using pty as device (notty or pty opt.) */
    160159extern int      log_to_fd;      /* logging to this fd as well as syslog */
    161160extern char     *no_ppp_msg;    /* message to print if ppp not in kernel */
    162 extern volatile int status;     /* exit status for pppd */
     161extern volatile int pppd_status;        /* exit status for pppd */
    163162extern int      devnam_fixed;   /* can no longer change devnam */
    164163extern int      unsuccess;      /* # unsuccessful connection attempts */
    165164extern int      do_callback;    /* set if we want to do callback next */
  • c/src/libnetworking/pppd//rtemsmain.c

    RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/rtemsmain.c,v
    retrieving revision 1.3
    diff -u -r1.3 rtemsmain.c
     
    7474char ifname[32];                /* Interface name */
    7575int pppifunit;                  /* Interface unit number */
    7676
    77 char *progname;                 /* Name of this program */
    7877char hostname[MAXNAMELEN];      /* Our hostname */
    7978static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
    8079
     
    8786struct stat devstat;            /* result of stat() on devnam */
    8887int prepass = 0;                /* doing prepass to find device name */
    8988int devnam_fixed;               /* set while in options.ttyxx file */
    90 volatile int status;            /* exit status for pppd */
     89volatile int pppd_status;               /* exit status for pppd */
    9190int unsuccess;                  /* # unsuccessful connection attempts */
    9291int do_callback;                /* != 0 if we should do callback next */
    9392int doing_callback;             /* != 0 if we are doing callback */
     
    102101static int pty_slave;           /* fd for slave side of pty */
    103102static int real_ttyfd;          /* fd for actual serial port (not pty) */
    104103
    105 int phase;                      /* where the link is at */
    106 int kill_link;
     104int pppd_phase;                 /* where the link is at */
     105int pppd_kill_link;
    107106int open_ccp_flag;
    108107
    109108char **script_env;              /* Env. variable values for scripts */
     
    195194        (*protp->init)(0);
    196195#endif
    197196
    198     progname = *argv;
    199 
    200197
    201198    if (!ppp_available()) {
    202199        option_error(no_ppp_msg);
     
    237234        need_holdoff = 1;
    238235        ttyfd = -1;
    239236        real_ttyfd = -1;
    240         status = EXIT_OK;
     237        pppd_status = EXIT_OK;
    241238        ++unsuccess;
    242239        doing_callback = do_callback;
    243240        do_callback = 0;
     
    260257         * in order to wait for the carrier detect signal from the modem.
    261258         */
    262259        hungup = 0;
    263         kill_link = 0;
     260        pppd_kill_link = 0;
    264261        connector = doing_callback? callback_script: connect_script;
    265262        if (devnam[0] != 0) {
    266263            for (;;) {
     
    275272                errno = err;
    276273                if (err != EINTR) {
    277274                    error("Failed to open %s: %m", devnam);
    278                     status = EXIT_OPEN_FAILED;
     275                    pppd_status = EXIT_OPEN_FAILED;
    279276                }
    280277                if (!persist || err != EINTR)
    281278                    goto fail;
     
    313310            if (initializer && initializer[0]) {
    314311                if (device_script(ttyfd, DIALER_INIT, initializer) < 0) {
    315312                    error("Initializer script failed");
    316                     status = EXIT_INIT_FAILED;
     313                    pppd_status = EXIT_INIT_FAILED;
    317314                    goto fail;
    318315                }
    319                 if (kill_link)
     316                if (pppd_kill_link)
    320317                    goto disconnect;
    321318
    322319                info("Serial port initialized.");
     
    325322            if (connector && connector[0]) {
    326323                if (device_script(ttyfd, DIALER_CONNECT, connector) < 0) {
    327324                    error("Connect script failed");
    328                     status = EXIT_CONNECT_FAILED;
     325                    pppd_status = EXIT_CONNECT_FAILED;
    329326                    goto fail;
    330327                }
    331                 if (kill_link)
     328                if (pppd_kill_link)
    332329                    goto disconnect;
    333330
    334331                info("Serial connection established.");
     
    350347                    break;
    351348                if (errno != EINTR) {
    352349                    error("Failed to reopen %s: %m", devnam);
    353                     status = EXIT_OPEN_FAILED;
     350                    pppd_status = EXIT_OPEN_FAILED;
    354351                }
    355                 if (!persist || errno != EINTR || hungup || kill_link)
     352                if (!persist || errno != EINTR || hungup || pppd_kill_link)
    356353                    goto fail;
    357354            }
    358355            close(i);
     
    370367        /* set up the serial device as a ppp interface */
    371368        fd_ppp = establish_ppp(ttyfd);
    372369        if (fd_ppp < 0) {
    373             status = EXIT_FATAL_ERROR;
     370            pppd_status = EXIT_FATAL_ERROR;
    374371            goto disconnect;
    375372        }
    376373
     
    390387        lcp_open(0);            /* Start protocol */
    391388
    392389        open_ccp_flag = 0;
    393         status = EXIT_NEGOTIATION_FAILED;
     390        pppd_status = EXIT_NEGOTIATION_FAILED;
    394391        new_phase(PHASE_ESTABLISH);
    395         while (phase != PHASE_DEAD) {
     392        while (pppd_phase != PHASE_DEAD) {
    396393            wait_input(timeleft(&timo));
    397394            calltimeout();
    398395            get_input();
    399396
    400             if (kill_link) {
     397            if (pppd_kill_link) {
    401398                lcp_close(0, "User request");
    402                 kill_link = 0;
     399                pppd_kill_link = 0;
    403400            }
    404401            if (open_ccp_flag) {
    405                 if (phase == PHASE_NETWORK || phase == PHASE_RUNNING) {
     402                if (pppd_phase == PHASE_NETWORK || pppd_phase == PHASE_RUNNING) {
    406403                    ccp_fsm[0].flags = OPT_RESTART; /* clears OPT_SILENT */
    407404                    (*ccp_protent.open)(0);
    408405                }
     
    450447        if (!persist || (maxfail > 0 && unsuccess >= maxfail))
    451448            break;
    452449
    453         kill_link = 0;
     450        pppd_kill_link = 0;
    454451        if (demand)
    455452            demand_discard();
    456453        t = need_holdoff? holdoff: 0;
     
    463460                wait_input(timeleft(&timo));
    464461
    465462                calltimeout();
    466                 if (kill_link) {
    467                     kill_link = 0;
     463                if (pppd_kill_link) {
     464                    pppd_kill_link = 0;
    468465                    new_phase(PHASE_DORMANT); /* allow signal to end holdoff */
    469466                }
    470             } while (phase == PHASE_HOLDOFF);
     467            } while (pppd_phase == PHASE_HOLDOFF);
    471468            if (!persist)
    472469                break;
    473470        }
    474471    }
    475472
    476     die(status);
    477     return status;
     473    die(pppd_status);
     474    return pppd_status;
    478475}
    479476
    480477/*
     
    591588    if (len == 0) {
    592589        notice("Modem hangup");
    593590        hungup = 1;
    594         status = EXIT_HANGUP;
     591        pppd_status = EXIT_HANGUP;
    595592        lcp_lowerdown(0);       /* serial link is no longer available */
    596593        link_terminated(0);
    597594        return;
     
    621618     * Until we get past the authentication phase, toss all packets
    622619     * except LCP, LQR and authentication packets.
    623620     */
    624     if (phase <= PHASE_AUTHENTICATE
     621    if (pppd_phase <= PHASE_AUTHENTICATE
    625622        && !(protocol == PPP_LCP || protocol == PPP_LQR
    626623             || protocol == PPP_PAP || protocol == PPP_CHAP)) {
    627624        MAINDEBUG(("get_input: discarding proto 0x%x in phase %d",
    628                    protocol, phase));
     625                   protocol, pppd_phase));
    629626        return;
    630627    }
    631628
     
    663660new_phase(p)
    664661    int p;
    665662{
    666     phase = p;
     663    pppd_phase = p;
    667664    if (new_phase_hook)
    668665        (*new_phase_hook)(p);
    669666}
  • c/src/libnetworking/pppd//rtemspppd.c

    RCS file: /usr1/CVS/rtems/c/src/libnetworking/pppd/rtemspppd.c,v
    retrieving revision 1.3
    diff -u -r1.3 rtemspppd.c
     
    177177    }
    178178
    179179    /* save current phase value */
    180     prevPhase = phase;
    181     phase     = PHASE_INITIALIZE;
     180    prevPhase = pppd_phase;
     181    pppd_phase     = PHASE_INITIALIZE;
    182182
    183183    /* process option and reset phase value */
    184184    iReturn = options_from_list(&option, 1);
    185     phase   = prevPhase;
     185    pppd_phase   = prevPhase;
    186186  }
    187187
    188188  return ( iReturn );
     
    200200{
    201201  /* set pppd global variables to disconnect */
    202202  persist   = 0;
    203   kill_link = 1;
     203  pppd_kill_link = 1;
    204204}
    205205
    206206int rtems_pppd_disconnect(void)