Changeset 4ca43d72 in rtems


Ignore:
Timestamp:
01/20/05 17:00:38 (19 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
1147a65
Parents:
982c61cc
Message:

2005-01-20 Joel Sherrill <joel@…>

PR 736/pppd

  • libnetworking/pppd/chat.c, libnetworking/pppd/demand.c, libnetworking/pppd/pppd.h, libnetworking/pppd/rtemsmain.c, libnetworking/pppd/sys-rtems.c, libnetworking/pppd/utils.c: ttyfd should not be static and should have a name more specific to pppd.
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • c/src/ChangeLog

    r982c61cc r4ca43d72  
     12005-01-20      Joel Sherrill <joel@OARcorp.com>
     2
     3        PR 736/pppd
     4        * libnetworking/pppd/chat.c, libnetworking/pppd/demand.c,
     5        libnetworking/pppd/pppd.h, libnetworking/pppd/rtemsmain.c,
     6        libnetworking/pppd/sys-rtems.c, libnetworking/pppd/utils.c: ttyfd
     7        should not be static and should have a name more specific to pppd.
     8
    192005-01-07      Ralf Corsepius <ralf.corsepius@rtems.org>
    210
  • c/src/libnetworking/pppd/chat.c

    r982c61cc r4ca43d72  
    164164static char *phone_num      = (char *) 0;
    165165static char *phone_num2     = (char *) 0;
    166 static int ttyfd;
     166/* static */ int pppd_ttyfd;
    167167static int timeout   = DEFAULT_CHAT_TIMEOUT;
    168168
     
    247247  /* initialize exit code */
    248248  exit_code = 0;
    249   ttyfd     = fd;
     249  pppd_ttyfd     = fd;
    250250
    251251  script=pScript;
     
    272272    }
    273273  }
    274   ttyfd = (int)-1;
     274  pppd_ttyfd = (int)-1;
    275275
    276276  return ( exit_code );
     
    279279void break_sequence()
    280280{
    281   tcsendbreak(ttyfd, 0);
     281  tcsendbreak(pppd_ttyfd, 0);
    282282}
    283283
     
    700700        while(tries)
    701701        {
    702             status = read(ttyfd, &c, 1);
     702            status = read(pppd_ttyfd, &c, 1);
    703703            switch (status) {
    704704                   case 1:
     
    716716  char ch = c;
    717717
    718   return(write(ttyfd, &ch, 1));
     718  return(write(pppd_ttyfd, &ch, 1));
    719719}
    720720
     
    792792    memset(temp2, 0, sizeof(temp2));
    793793
    794     tcgetattr(ttyfd, &tios);
     794    tcgetattr(pppd_ttyfd, &tios);
    795795    tios.c_cc[VMIN] = 0;
    796796    tios.c_cc[VTIME] = timeout*10/MAX_TIMEOUTS;
    797     tcsetattr(ttyfd, TCSANOW, &tios);
     797    tcsetattr(pppd_ttyfd, TCSANOW, &tios);
    798798               
    799799    string = clean(in_string, 0);
  • c/src/libnetworking/pppd/demand.c

    r982c61cc r4ca43d72  
    4646static const char rcsid[] = RCSID;
    4747
    48 static char *frame;
     48static unsigned char *frame;
    4949static int framelen;
    5050static int framemax;
  • c/src/libnetworking/pppd/pppd.h

    r982c61cc r4ca43d72  
    142142extern int      pppifunit;      /* Interface unit number */
    143143extern char     ifname[];       /* Interface name */
    144 extern int      ttyfd;          /* Serial device file descriptor */
     144extern int      pppd_ttyfd;     /* Serial device file descriptor */
    145145extern char     hostname[];     /* Our hostname */
    146146extern u_char   outpacket_buf[]; /* Buffer for outgoing packets */
     
    302302void log_packet __P((u_char *, int, char *, int));
    303303                                /* Format a packet and log it with syslog */
    304 void print_string __P((char *, int,  void (*) (void *, char *, ...),
     304void print_string __P((void *, int,  void (*) (void *, char *, ...),
    305305                void *));       /* Format a string for output */
    306306int slprintf __P((char *, int, char *, ...));           /* sprintf++ */
  • c/src/libnetworking/pppd/rtemsmain.c

    r982c61cc r4ca43d72  
    7878static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
    7979
    80 int ttyfd;                      /* Serial port file descriptor */
     80/* int pppd_ttyfd;                      * Serial port file descriptor */
    8181int baud_rate;                  /* Actual bits/second for serial device */
    8282int hungup;                     /* terminal has been hung up */
     
    233233
    234234        need_holdoff = 1;
    235         ttyfd = -1;
     235        pppd_ttyfd = -1;
    236236        real_ttyfd = -1;
    237237        pppd_status = EXIT_OK;
     
    265265                   user before opening it. */
    266266                int err;
    267                 ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
     267                pppd_ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
    268268                err = errno;
    269                 if (ttyfd >= 0) {
     269                if (pppd_ttyfd >= 0) {
    270270                    break;
    271271                }
     
    278278                    goto fail;
    279279            }
    280             if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1
    281                 || fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
     280            if ((fdflags = fcntl(pppd_ttyfd, F_GETFL)) == -1
     281                || fcntl(pppd_ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
    282282                warn("Couldn't reset non-blocking mode on device: %m");
    283283
     
    292292             * we could clear CLOCAL at this point.
    293293             */
    294             set_up_tty(ttyfd, ((connector != NULL && connector[0] != 0)
     294            set_up_tty(pppd_ttyfd, ((connector != NULL && connector[0] != 0)
    295295                               || initializer != NULL));
    296             real_ttyfd = ttyfd;
     296            real_ttyfd = pppd_ttyfd;
    297297        }
    298298
     
    309309
    310310            if (initializer && initializer[0]) {
    311                 if (device_script(ttyfd, DIALER_INIT, initializer) < 0) {
     311                if (device_script(pppd_ttyfd, DIALER_INIT, initializer) < 0) {
    312312                    error("Initializer script failed");
    313313                    pppd_status = EXIT_INIT_FAILED;
     
    321321
    322322            if (connector && connector[0]) {
    323                 if (device_script(ttyfd, DIALER_CONNECT, connector) < 0) {
     323                if (device_script(pppd_ttyfd, DIALER_CONNECT, connector) < 0) {
    324324                    error("Connect script failed");
    325325                    pppd_status = EXIT_CONNECT_FAILED;
     
    361361        /* run welcome script, if any */
    362362        if (welcomer && welcomer[0]) {
    363             if (device_script(ttyfd, DIALER_WELCOME, welcomer) < 0)
     363            if (device_script(pppd_ttyfd, DIALER_WELCOME, welcomer) < 0)
    364364                warn("Welcome script failed");
    365365        }
    366366
    367367        /* set up the serial device as a ppp interface */
    368         fd_ppp = establish_ppp(ttyfd);
     368        fd_ppp = establish_ppp(pppd_ttyfd);
    369369        if (fd_ppp < 0) {
    370370            pppd_status = EXIT_FATAL_ERROR;
     
    416416        if (demand)
    417417            restore_loop();
    418         disestablish_ppp(ttyfd);
     418        disestablish_ppp(pppd_ttyfd);
    419419        fd_ppp = -1;
    420420        if (!hungup)
     
    430430            if (real_ttyfd >= 0)
    431431                set_up_tty(real_ttyfd, 1);
    432             if (device_script(ttyfd, DIALER_DISCONNECT, disconnect_script) < 0) {
     432            if (device_script(pppd_ttyfd, DIALER_DISCONNECT, disconnect_script) < 0) {
    433433                warn("disconnect script failed");
    434434            } else {
     
    686686
    687687    if (fd_ppp >= 0)
    688         disestablish_ppp(ttyfd);
     688        disestablish_ppp(pppd_ttyfd);
    689689    if (real_ttyfd >= 0)
    690690        close_tty();
  • c/src/libnetworking/pppd/sys-rtems.c

    r982c61cc r4ca43d72  
    489489/*    printf("sent packet [%d]\n", len); */
    490490
    491     if (write(ttyfd, p, len) < 0) {
     491    if (write(pppd_ttyfd, p, len) < 0) {
    492492        if (errno != EIO)
    493493            error("write: %m");
     
    532532    int len;
    533533
    534     if ((len = read(ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
     534    if ((len = read(pppd_ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
    535535        if (errno == EWOULDBLOCK || errno == EINTR) len = -1;
    536536        /*fatal("read: %m"); */
     
    650650    data.length = opt_len;
    651651    data.transmit = for_transmit;
    652     if (ioctl(ttyfd, PPPIOCSCOMPRESS, (caddr_t) &data) >= 0)
     652    if (ioctl(pppd_ttyfd, PPPIOCSCOMPRESS, (caddr_t) &data) >= 0)
    653653        return 1;
    654654    return (errno == ENOBUFS)? 0: -1;
  • c/src/libnetworking/pppd/utils.c

    r982c61cc r4ca43d72  
    469469 */
    470470void
    471 print_string(p, len, printer, arg)
    472     char *p;
     471print_string(p_arg, len, printer, arg)
     472    void *p_arg;
    473473    int len;
    474474    void (*printer) __P((void *, char *, ...));
     
    476476{
    477477    int c;
     478    unsigned char *p = (unsigned char *)p_arg;
    478479
    479480    printer(arg, "\"");
  • cpukit/pppd/chat.c

    r982c61cc r4ca43d72  
    164164static char *phone_num      = (char *) 0;
    165165static char *phone_num2     = (char *) 0;
    166 static int ttyfd;
     166/* static */ int pppd_ttyfd;
    167167static int timeout   = DEFAULT_CHAT_TIMEOUT;
    168168
     
    247247  /* initialize exit code */
    248248  exit_code = 0;
    249   ttyfd     = fd;
     249  pppd_ttyfd     = fd;
    250250
    251251  script=pScript;
     
    272272    }
    273273  }
    274   ttyfd = (int)-1;
     274  pppd_ttyfd = (int)-1;
    275275
    276276  return ( exit_code );
     
    279279void break_sequence()
    280280{
    281   tcsendbreak(ttyfd, 0);
     281  tcsendbreak(pppd_ttyfd, 0);
    282282}
    283283
     
    700700        while(tries)
    701701        {
    702             status = read(ttyfd, &c, 1);
     702            status = read(pppd_ttyfd, &c, 1);
    703703            switch (status) {
    704704                   case 1:
     
    716716  char ch = c;
    717717
    718   return(write(ttyfd, &ch, 1));
     718  return(write(pppd_ttyfd, &ch, 1));
    719719}
    720720
     
    792792    memset(temp2, 0, sizeof(temp2));
    793793
    794     tcgetattr(ttyfd, &tios);
     794    tcgetattr(pppd_ttyfd, &tios);
    795795    tios.c_cc[VMIN] = 0;
    796796    tios.c_cc[VTIME] = timeout*10/MAX_TIMEOUTS;
    797     tcsetattr(ttyfd, TCSANOW, &tios);
     797    tcsetattr(pppd_ttyfd, TCSANOW, &tios);
    798798               
    799799    string = clean(in_string, 0);
  • cpukit/pppd/demand.c

    r982c61cc r4ca43d72  
    4646static const char rcsid[] = RCSID;
    4747
    48 static char *frame;
     48static unsigned char *frame;
    4949static int framelen;
    5050static int framemax;
  • cpukit/pppd/pppd.h

    r982c61cc r4ca43d72  
    142142extern int      pppifunit;      /* Interface unit number */
    143143extern char     ifname[];       /* Interface name */
    144 extern int      ttyfd;          /* Serial device file descriptor */
     144extern int      pppd_ttyfd;     /* Serial device file descriptor */
    145145extern char     hostname[];     /* Our hostname */
    146146extern u_char   outpacket_buf[]; /* Buffer for outgoing packets */
     
    302302void log_packet __P((u_char *, int, char *, int));
    303303                                /* Format a packet and log it with syslog */
    304 void print_string __P((char *, int,  void (*) (void *, char *, ...),
     304void print_string __P((void *, int,  void (*) (void *, char *, ...),
    305305                void *));       /* Format a string for output */
    306306int slprintf __P((char *, int, char *, ...));           /* sprintf++ */
  • cpukit/pppd/rtemsmain.c

    r982c61cc r4ca43d72  
    7878static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
    7979
    80 int ttyfd;                      /* Serial port file descriptor */
     80/* int pppd_ttyfd;                      * Serial port file descriptor */
    8181int baud_rate;                  /* Actual bits/second for serial device */
    8282int hungup;                     /* terminal has been hung up */
     
    233233
    234234        need_holdoff = 1;
    235         ttyfd = -1;
     235        pppd_ttyfd = -1;
    236236        real_ttyfd = -1;
    237237        pppd_status = EXIT_OK;
     
    265265                   user before opening it. */
    266266                int err;
    267                 ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
     267                pppd_ttyfd = open(devnam, O_NONBLOCK | O_RDWR, 0);
    268268                err = errno;
    269                 if (ttyfd >= 0) {
     269                if (pppd_ttyfd >= 0) {
    270270                    break;
    271271                }
     
    278278                    goto fail;
    279279            }
    280             if ((fdflags = fcntl(ttyfd, F_GETFL)) == -1
    281                 || fcntl(ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
     280            if ((fdflags = fcntl(pppd_ttyfd, F_GETFL)) == -1
     281                || fcntl(pppd_ttyfd, F_SETFL, fdflags & ~O_NONBLOCK) < 0)
    282282                warn("Couldn't reset non-blocking mode on device: %m");
    283283
     
    292292             * we could clear CLOCAL at this point.
    293293             */
    294             set_up_tty(ttyfd, ((connector != NULL && connector[0] != 0)
     294            set_up_tty(pppd_ttyfd, ((connector != NULL && connector[0] != 0)
    295295                               || initializer != NULL));
    296             real_ttyfd = ttyfd;
     296            real_ttyfd = pppd_ttyfd;
    297297        }
    298298
     
    309309
    310310            if (initializer && initializer[0]) {
    311                 if (device_script(ttyfd, DIALER_INIT, initializer) < 0) {
     311                if (device_script(pppd_ttyfd, DIALER_INIT, initializer) < 0) {
    312312                    error("Initializer script failed");
    313313                    pppd_status = EXIT_INIT_FAILED;
     
    321321
    322322            if (connector && connector[0]) {
    323                 if (device_script(ttyfd, DIALER_CONNECT, connector) < 0) {
     323                if (device_script(pppd_ttyfd, DIALER_CONNECT, connector) < 0) {
    324324                    error("Connect script failed");
    325325                    pppd_status = EXIT_CONNECT_FAILED;
     
    361361        /* run welcome script, if any */
    362362        if (welcomer && welcomer[0]) {
    363             if (device_script(ttyfd, DIALER_WELCOME, welcomer) < 0)
     363            if (device_script(pppd_ttyfd, DIALER_WELCOME, welcomer) < 0)
    364364                warn("Welcome script failed");
    365365        }
    366366
    367367        /* set up the serial device as a ppp interface */
    368         fd_ppp = establish_ppp(ttyfd);
     368        fd_ppp = establish_ppp(pppd_ttyfd);
    369369        if (fd_ppp < 0) {
    370370            pppd_status = EXIT_FATAL_ERROR;
     
    416416        if (demand)
    417417            restore_loop();
    418         disestablish_ppp(ttyfd);
     418        disestablish_ppp(pppd_ttyfd);
    419419        fd_ppp = -1;
    420420        if (!hungup)
     
    430430            if (real_ttyfd >= 0)
    431431                set_up_tty(real_ttyfd, 1);
    432             if (device_script(ttyfd, DIALER_DISCONNECT, disconnect_script) < 0) {
     432            if (device_script(pppd_ttyfd, DIALER_DISCONNECT, disconnect_script) < 0) {
    433433                warn("disconnect script failed");
    434434            } else {
     
    686686
    687687    if (fd_ppp >= 0)
    688         disestablish_ppp(ttyfd);
     688        disestablish_ppp(pppd_ttyfd);
    689689    if (real_ttyfd >= 0)
    690690        close_tty();
  • cpukit/pppd/sys-rtems.c

    r982c61cc r4ca43d72  
    489489/*    printf("sent packet [%d]\n", len); */
    490490
    491     if (write(ttyfd, p, len) < 0) {
     491    if (write(pppd_ttyfd, p, len) < 0) {
    492492        if (errno != EIO)
    493493            error("write: %m");
     
    532532    int len;
    533533
    534     if ((len = read(ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
     534    if ((len = read(pppd_ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
    535535        if (errno == EWOULDBLOCK || errno == EINTR) len = -1;
    536536        /*fatal("read: %m"); */
     
    650650    data.length = opt_len;
    651651    data.transmit = for_transmit;
    652     if (ioctl(ttyfd, PPPIOCSCOMPRESS, (caddr_t) &data) >= 0)
     652    if (ioctl(pppd_ttyfd, PPPIOCSCOMPRESS, (caddr_t) &data) >= 0)
    653653        return 1;
    654654    return (errno == ENOBUFS)? 0: -1;
  • cpukit/pppd/utils.c

    r982c61cc r4ca43d72  
    469469 */
    470470void
    471 print_string(p, len, printer, arg)
    472     char *p;
     471print_string(p_arg, len, printer, arg)
     472    void *p_arg;
    473473    int len;
    474474    void (*printer) __P((void *, char *, ...));
     
    476476{
    477477    int c;
     478    unsigned char *p = (unsigned char *)p_arg;
    478479
    479480    printer(arg, "\"");
Note: See TracChangeset for help on using the changeset viewer.