Changeset 0286b9f in rtems


Ignore:
Timestamp:
Jan 31, 2002, 9:42:11 PM (18 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.8, 4.9, master
Children:
5ec6f09
Parents:
d8a78f4f
Message:

2001-01-31 Mike Siers <mikes@…>

  • Nice Update of PPPD support which eliminates the requiremetn that drivers be in the termios TASK_DRIVEN mode. Mike did significant testing and reports that it seems to be more stable and handle larger packets better. This patch replaces the termios tasks with more general pppd network driver tasks. The functions pppinput() and pppstart() get called from the interrupt service routine.
  • Makefile.am, configure.ac, net/Makefile.am, net/bpf.h, net/ethernet.h, net/if.c, net/if.h, net/if_arp.h, net/if_dl.h, net/if_ethersubr.c, net/if_llc.h, net/if_loop.c, net/if_ppp.h, net/if_pppvar.h, net/if_types.h, net/netisr.h, net/ppp-comp.h, net/ppp_defs.h, net/pppcompress.h, net/radix.c, net/radix.h, net/raw_cb.c, net/raw_cb.h, net/raw_usrreq.c, net/route.c, net/route.h, net/rtsock.c, pppd/Makefile.am, pppd/README, pppd/STATUS, pppd/auth.c, pppd/cbcp.c, pppd/ccp.c, pppd/ccp.h, pppd/chap.c, pppd/chap.h, pppd/chap_ms.c, pppd/chap_ms.h, pppd/chat.c, pppd/demand.c, pppd/fsm.c, pppd/fsm.h, pppd/ipcp.c, pppd/ipcp.h, pppd/ipxcp.c, pppd/ipxcp.h, pppd/lcp.c, pppd/lcp.h, pppd/magic.c, pppd/magic.h, pppd/options.c, pppd/patchlevel.h, pppd/pathnames.h, pppd/pppd.8, pppd/pppd.h, pppd/rtemsmain.c, pppd/rtemspppd.c, pppd/rtemspppd.h, pppd/sys-rtems.c, pppd/upap.c, pppd/upap.h, pppd/utils.c, pppd/example/README, pppd/example/netconfig.h, wrapup/Makefile.am: Modified.
  • net/bsd-comp.c, net/if_ppp.c, net/ppp-deflate.c, net/ppp.h, net/ppp_tty.c, net/pppcompress.c, net/zlib.c, net/zlib.h: New file.
  • modem/, modem/.cvsignore, modem/Makefile.am, modem/ppp.c, modem/ppp.h, modem/ppp_tty.c, modem/pppcompress.c: Subdirectory removed.
Files:
22 added
4 deleted
59 edited
2 moved

Legend:

Unmodified
Added
Removed
  • c/src/exec/libnetworking/ChangeLog

    rd8a78f4f r0286b9f  
     12001-01-31      Mike Siers <mikes@poliac.com>
     2
     3        * Nice Update of PPPD support which eliminates the
     4        requiremetn that drivers be in the termios TASK_DRIVEN mode.
     5        Mike did significant testing and reports that it seems to be
     6        more stable and handle larger packets better.  This patch
     7        replaces the termios tasks with more general pppd network
     8        driver tasks.  The functions pppinput() and pppstart() get
     9        called from the interrupt service routine.
     10        * Makefile.am, configure.ac, net/Makefile.am, net/bpf.h,
     11        net/ethernet.h, net/if.c, net/if.h, net/if_arp.h, net/if_dl.h,
     12        net/if_ethersubr.c, net/if_llc.h, net/if_loop.c, net/if_ppp.h,
     13        net/if_pppvar.h, net/if_types.h, net/netisr.h, net/ppp-comp.h,
     14        net/ppp_defs.h, net/pppcompress.h, net/radix.c, net/radix.h,
     15        net/raw_cb.c, net/raw_cb.h, net/raw_usrreq.c, net/route.c,
     16        net/route.h, net/rtsock.c, pppd/Makefile.am, pppd/README,
     17        pppd/STATUS, pppd/auth.c, pppd/cbcp.c, pppd/ccp.c, pppd/ccp.h,
     18        pppd/chap.c, pppd/chap.h, pppd/chap_ms.c, pppd/chap_ms.h,
     19        pppd/chat.c, pppd/demand.c, pppd/fsm.c, pppd/fsm.h, pppd/ipcp.c,
     20        pppd/ipcp.h, pppd/ipxcp.c, pppd/ipxcp.h, pppd/lcp.c, pppd/lcp.h,
     21        pppd/magic.c, pppd/magic.h, pppd/options.c, pppd/patchlevel.h,
     22        pppd/pathnames.h, pppd/pppd.8, pppd/pppd.h, pppd/rtemsmain.c,
     23        pppd/rtemspppd.c, pppd/rtemspppd.h, pppd/sys-rtems.c, pppd/upap.c,
     24        pppd/upap.h, pppd/utils.c, pppd/example/README,
     25        pppd/example/netconfig.h, wrapup/Makefile.am: Modified.
     26        * net/bsd-comp.c, net/if_ppp.c, net/ppp-deflate.c, net/ppp.h,
     27        net/ppp_tty.c, net/pppcompress.c, net/zlib.c, net/zlib.h: New file.
     28        * modem/, modem/.cvsignore, modem/Makefile.am, modem/ppp.c,
     29        modem/ppp.h, modem/ppp_tty.c, modem/pppcompress.c: Subdirectory removed.
     30
    1312002-01-21      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    232
  • c/src/exec/libnetworking/Makefile.am

    rd8a78f4f r0286b9f  
    77
    88SUBDIRS = arpa kern machine sys vm lib libc net netinet nfs rtems \
    9     rtems_servers pppd modem rtems_telnetd rtems_webserver wrapup
     9    rtems_servers pppd rtems_telnetd rtems_webserver wrapup
    1010
    1111include_HEADERS = \
  • c/src/exec/libnetworking/configure.ac

    rd8a78f4f r0286b9f  
    4747nfs/Makefile
    4848pppd/Makefile
    49 modem/Makefile
    5049rtems/Makefile
    5150rtems_servers/Makefile
  • c/src/exec/libnetworking/net/Makefile.am

    rd8a78f4f r0286b9f  
    1111
    1212C_FILES = if.c if_ethersubr.c if_loop.c radix.c route.c rtsock.c raw_cb.c \
    13     raw_usrreq.c
     13    raw_usrreq.c if_ppp.c ppp_tty.c pppcompress.c
    1414C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)
    1515
  • c/src/exec/libnetworking/net/if_ppp.h

    rd8a78f4f r0286b9f  
    3939#define SC_LOG_RAWIN    0x00080000      /* log all chars received */
    4040#define SC_LOG_FLUSH    0x00100000      /* log all chars flushed */
    41 #define SC_SYNC         0x00200000      /* synchrounous HDLC */
    4241#define SC_RCV_B7_0     0x01000000      /* have rcvd char with bit 7 = 0 */
    4342#define SC_RCV_B7_1     0x02000000      /* have rcvd char with bit 7 = 1 */
    4443#define SC_RCV_EVNP     0x04000000      /* have rcvd char with even parity */
    4544#define SC_RCV_ODDP     0x08000000      /* have rcvd char with odd parity */
     45#define SC_SYNC         0x00200000      /* use synchronous HDLC framing */
    4646#define SC_MASK         0x0fff00ff      /* bits that user can change */
    4747
     
    9090 */
    9191
     92#define PPPIOCSTASK     _IOW('t', 91, int)      /* set pppd task id */
    9293#define PPPIOCGFLAGS    _IOR('t', 90, int)      /* get configuration flags */
    9394#define PPPIOCSFLAGS    _IOW('t', 89, int)      /* set configuration flags */
  • c/src/exec/libnetworking/net/if_pppvar.h

    rd8a78f4f r0286b9f  
    4646 * indexing sc_npmode.
    4747 */
    48 #define NP_IP   0               /* Internet Protocol */
    49 #define NUM_NP  1               /* Number of NPs. */
     48#define NP_IP                 0 /* Internet Protocol */
     49#define NUM_NP                1 /* Number of NPs. */
     50#define NUM_MBUFQ            64
     51
    5052
    5153/*
     
    6466        struct  ifqueue sc_inq;         /* queue of input packets for daemon */
    6567        struct  ifqueue sc_fastq;       /* interactive output packet q */
    66         struct  mbuf *sc_togo;          /* output packet ready to go */
    6768        struct  mbuf *sc_npqueue;       /* output packets not to be sent yet */
    6869        struct  mbuf **sc_npqtail;      /* ptr to last next ptr in npqueue */
     
    8586
    8687        /* Device-dependent part for async lines. */
    87         ext_accm sc_asyncmap;           /* async control character map */
    88         u_long  sc_rasyncmap;           /* receive async control char map */
    89         struct  mbuf *sc_outm;          /* mbuf chain currently being output */
    90         struct  mbuf *sc_m;             /* pointer to input mbuf chain */
    91         struct  mbuf *sc_mc;            /* pointer to current input mbuf */
    92         char    *sc_mp;                 /* ptr to next char in input mbuf */
    93         short   sc_ilen;                /* length of input packet so far */
    94         u_short sc_fcs;                 /* FCS so far (input) */
    95         u_short sc_outfcs;              /* FCS so far for output packet */
    96         u_char  sc_rawin[16];           /* chars as received */
    97         int     sc_rawin_count;         /* # in sc_rawin */
    98         rtems_id sem_id;                /* ID of comm semaphore         */
     88        ext_accm sc_asyncmap;                /* async control character map */
     89        u_long  sc_rasyncmap;                /* receive async control char map */
     90        struct  mbuf *sc_outm;               /* mbuf chain currently being output */
     91        struct  mbuf *sc_outmc;              /* mbuf currently being output */
     92        struct  mbuf *sc_m;                  /* pointer to input mbuf chain */
     93        struct  mbuf *sc_mc;                 /* pointer to current input mbuf */
     94        char    *sc_mp;                      /* ptr to next char in input mbuf */
     95        short   sc_ilen;                     /* length of input packet so far */
     96        u_short sc_fcs;                      /* FCS so far (input) */
     97        u_char  sc_rawin[16];                /* chars as received */
     98        int     sc_rawin_count;              /* # in sc_rawin */
     99        u_short sc_outfcs;                   /* FCS so far for output packet */
     100
     101        struct  ifqueue sc_freeq;            /* free packets */
     102        short   sc_outoff;                   /* output packet byte offset */
     103        short   sc_outflag;                  /* output status flag */
     104        short   sc_outlen;                   /* length of output packet */
     105        short   sc_outfcslen;                /* length of output fcs data */
     106        u_char  sc_outfcsbuf[8];             /* output packet fcs buffer */
     107        u_char *sc_outbuf;                   /* pointer to output data */
     108
     109        rtems_id sc_rxtask;
     110        rtems_id sc_txtask;
     111        rtems_id sc_pppdtask;
    99112};
    100113
     
    107120int     pppioctl __P((struct ppp_softc *sc, int cmd, caddr_t data,
    108121                      int flag, struct proc *p));
    109 void    ppp_restart __P((struct ppp_softc *sc));
    110 void    ppppktin __P((struct ppp_softc *sc, struct mbuf *m, int lost));
    111122struct  mbuf *ppp_dequeue __P((struct ppp_softc *sc));
     123u_short pppfcs __P((u_short fcs, u_char *cp, int len));
     124void    pppallocmbuf __P((struct ppp_softc *sc, struct mbuf **mp));
     125
     126
     127/* define event values */
     128#define RX_PACKET    RTEMS_EVENT_1
     129#define RX_MBUF      RTEMS_EVENT_2
     130#define RX_EMPTY     RTEMS_EVENT_3
     131#define TX_PACKET    RTEMS_EVENT_1
     132#define TX_TRANSMIT  RTEMS_EVENT_2
     133#define PPPD_EVENT   RTEMS_EVENT_31
     134
     135/* define out flag values */
     136#define SC_TX_BUSY      0x0001
     137#define SC_TX_FCS       0x0002
     138#define SC_TX_ESCAPE    0x0004
     139#define SC_TX_PENDING   0x0010
  • c/src/exec/libnetworking/net/ppp-comp.h

    rd8a78f4f r0286b9f  
    3636 */
    3737#ifndef DO_BSD_COMPRESS
    38 #define DO_BSD_COMPRESS 1       /* by default, include BSD-Compress */
     38#define DO_BSD_COMPRESS 0       /* by default, include BSD-Compress */
    3939#endif
    4040#ifndef DO_DEFLATE
    41 #define DO_DEFLATE      1       /* by default, include Deflate */
     41#define DO_DEFLATE      0       /* by default, include Deflate */
    4242#endif
    4343#define DO_PREDICTOR_1  0
  • c/src/exec/libnetworking/net/ppp_defs.h

    rd8a78f4f r0286b9f  
    7878#define PPP_ATCP        0x8029  /* AppleTalk Control Protocol */
    7979#define PPP_IPXCP       0x802b  /* IPX Control Protocol */
     80#define PPP_IPV6CP      0x8057  /* IPv6 Control Protocol */
    8081#define PPP_CCP         0x80fd  /* Compression Control Protocol */
    8182#define PPP_LCP         0xc021  /* Link Control Protocol */
     
    9798
    9899#if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) \
    99  && !defined(__FreeBSD__) && (NS_TARGET < 40) && !defined(__rtems__)
     100 && !defined(__FreeBSD__) && (NS_TARGET < 40)
    100101#ifdef  UINT32_T
    101102typedef UINT32_T        u_int32_t;
    102103#else
    103 typedef unsigned int    u_int32_t;
    104 typedef unsigned short  u_int16_t;
     104/*typedef unsigned int  u_int32_t;*/
     105/*typedef unsigned short  u_int16_t;*/
    105106#endif
    106107#endif
  • c/src/exec/libnetworking/wrapup/Makefile.am

    rd8a78f4f r0286b9f  
    99endif
    1010
    11 NET_O_PIECES = kern lib libc net netinet nfs rtems rtems_servers rtems_telnetd pppd modem \
    12     $(POSIX_PIECES)
     11NET_O_PIECES = kern lib libc net netinet nfs rtems rtems_servers \
     12    rtems_telnetd pppd $(POSIX_PIECES)
    1313OBJS = $(foreach piece, $(NET_O_PIECES), ../$(piece)/$(ARCH)/*.o)
    1414LIB = $(ARCH)/libnetworking.a
  • c/src/libnetworking/ChangeLog

    rd8a78f4f r0286b9f  
     12001-01-31      Mike Siers <mikes@poliac.com>
     2
     3        * Nice Update of PPPD support which eliminates the
     4        requiremetn that drivers be in the termios TASK_DRIVEN mode.
     5        Mike did significant testing and reports that it seems to be
     6        more stable and handle larger packets better.  This patch
     7        replaces the termios tasks with more general pppd network
     8        driver tasks.  The functions pppinput() and pppstart() get
     9        called from the interrupt service routine.
     10        * Makefile.am, configure.ac, net/Makefile.am, net/bpf.h,
     11        net/ethernet.h, net/if.c, net/if.h, net/if_arp.h, net/if_dl.h,
     12        net/if_ethersubr.c, net/if_llc.h, net/if_loop.c, net/if_ppp.h,
     13        net/if_pppvar.h, net/if_types.h, net/netisr.h, net/ppp-comp.h,
     14        net/ppp_defs.h, net/pppcompress.h, net/radix.c, net/radix.h,
     15        net/raw_cb.c, net/raw_cb.h, net/raw_usrreq.c, net/route.c,
     16        net/route.h, net/rtsock.c, pppd/Makefile.am, pppd/README,
     17        pppd/STATUS, pppd/auth.c, pppd/cbcp.c, pppd/ccp.c, pppd/ccp.h,
     18        pppd/chap.c, pppd/chap.h, pppd/chap_ms.c, pppd/chap_ms.h,
     19        pppd/chat.c, pppd/demand.c, pppd/fsm.c, pppd/fsm.h, pppd/ipcp.c,
     20        pppd/ipcp.h, pppd/ipxcp.c, pppd/ipxcp.h, pppd/lcp.c, pppd/lcp.h,
     21        pppd/magic.c, pppd/magic.h, pppd/options.c, pppd/patchlevel.h,
     22        pppd/pathnames.h, pppd/pppd.8, pppd/pppd.h, pppd/rtemsmain.c,
     23        pppd/rtemspppd.c, pppd/rtemspppd.h, pppd/sys-rtems.c, pppd/upap.c,
     24        pppd/upap.h, pppd/utils.c, pppd/example/README,
     25        pppd/example/netconfig.h, wrapup/Makefile.am: Modified.
     26        * net/bsd-comp.c, net/if_ppp.c, net/ppp-deflate.c, net/ppp.h,
     27        net/ppp_tty.c, net/pppcompress.c, net/zlib.c, net/zlib.h: New file.
     28        * modem/, modem/.cvsignore, modem/Makefile.am, modem/ppp.c,
     29        modem/ppp.h, modem/ppp_tty.c, modem/pppcompress.c: Subdirectory removed.
     30
    1312002-01-21      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    232
  • c/src/libnetworking/Makefile.am

    rd8a78f4f r0286b9f  
    77
    88SUBDIRS = arpa kern machine sys vm lib libc net netinet nfs rtems \
    9     rtems_servers pppd modem rtems_telnetd rtems_webserver wrapup
     9    rtems_servers pppd rtems_telnetd rtems_webserver wrapup
    1010
    1111include_HEADERS = \
  • c/src/libnetworking/configure.ac

    rd8a78f4f r0286b9f  
    4747nfs/Makefile
    4848pppd/Makefile
    49 modem/Makefile
    5049rtems/Makefile
    5150rtems_servers/Makefile
  • c/src/libnetworking/net/Makefile.am

    rd8a78f4f r0286b9f  
    1111
    1212C_FILES = if.c if_ethersubr.c if_loop.c radix.c route.c rtsock.c raw_cb.c \
    13     raw_usrreq.c
     13    raw_usrreq.c if_ppp.c ppp_tty.c pppcompress.c
    1414C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)
    1515
  • c/src/libnetworking/net/if_ppp.c

    rd8a78f4f r0286b9f  
    7676#include "ppp.h"
    7777#if NPPP > 0
    78 /* temporarily we switch off the compression */
    79 
    80 #include <rtems/rtems_bsdnet.h> /* to get right defines */
    81 
     78
     79#include <termios.h>
     80#include <rtems/termiostypes.h>
     81#include <rtems/rtems_bsdnet.h>
    8282#include <sys/param.h>
    8383#include <sys/systm.h>
     
    9090#include <sys/malloc.h>
    9191
    92 #include <rtems/rtems_bsdnet.h>
    9392#include <net/if.h>
    94 #include <sys/errno.h>
    9593#include <net/if_types.h>
    9694#include <net/netisr.h>
     
    10098#endif
    10199
    102 #ifdef INET
     100#if INET
    103101#include <netinet/in.h>
    104102#include <netinet/in_systm.h>
     
    107105#endif
    108106
    109 #include <bpfilter.h>
     107#include "bpfilter.h"
    110108#if NBPFILTER > 0
    111109#include <net/bpf.h>
     
    123121#define splsoftnet      splnet
    124122
    125 #ifndef NETISR_PPP
    126 /* This definition should be moved to net/netisr.h */
    127 #define NETISR_PPP      26      /* PPP software interrupt */
    128 #endif
    129 
    130123#ifdef PPP_COMPRESS
    131124#define PACKETPTR       struct mbuf *
    132125#include <net/ppp-comp.h>
    133126#endif
    134 extern struct   ifqueue ipintrq;
     127
    135128static int      pppsioctl __P((struct ifnet *, int, caddr_t));
    136129static void     ppp_requeue __P((struct ppp_softc *));
     
    139132static void     ppp_ccp_closed __P((struct ppp_softc *));
    140133#endif
    141 static void     ppp_inproc __P((struct ppp_softc *, struct mbuf *));
     134static struct mbuf *ppp_inproc __P((struct ppp_softc *, struct mbuf *));
    142135static void     pppdumpm __P((struct mbuf *m0));
    143136
     
    172165extern struct compressor ppp_deflate, ppp_deflate_draft;
    173166
    174 
    175167struct compressor *ppp_compressors[8] = {
    176168#if DO_BSD_COMPRESS
     
    184176};
    185177#endif /* PPP_COMPRESS */
    186 static struct timeval ppp_time;
    187 
    188 TEXT_SET(pseudo_set, pppattach);
     178
     179extern struct ifqueue    ipintrq;
     180static struct timeval    ppp_time;
     181
     182TEXT_SET(pseudo_set, ppp_rxdaemon);
     183
     184
     185static rtems_task ppp_rxdaemon(rtems_task_argument arg)
     186{
     187  rtems_event_set             events;
     188  rtems_interrupt_level       level;
     189  struct ppp_softc           *sc = (struct ppp_softc *)arg;
     190  struct mbuf                *mp = (struct mbuf      *)0;
     191  struct mbuf                *m;
     192
     193  /* enter processing loop */
     194  while ( 1 ) {
     195    /* wait for event */
     196    rtems_event_receive(RX_PACKET|RX_MBUF|RX_EMPTY,RTEMS_WAIT|RTEMS_EVENT_ANY,RTEMS_NO_TIMEOUT,&events);
     197    if ( events & RX_EMPTY ) {
     198      printf("RX: QUEUE is EMPTY\n");
     199      events &= ~RX_EMPTY;
     200    }
     201
     202    if ( events ) {
     203      /* get the network semaphore */
     204      rtems_bsdnet_semaphore_obtain();
     205
     206      /* check to see if new packet was received */
     207      if ( events & RX_PACKET ) {
     208        /* get received packet mbuf chain */
     209        rtems_interrupt_disable(level);
     210        IF_DEQUEUE(&sc->sc_rawq, m);
     211        rtems_interrupt_enable(level);
     212
     213        /* ensure packet was retrieved */
     214        if ( m != (struct mbuf *)0 ) {
     215          /* process the received packet */
     216          mp = ppp_inproc(sc, m);
     217        }
     218      }
     219
     220      /* allocate a new mbuf to replace one */
     221      if ( mp == NULL ) {
     222        pppallocmbuf(sc, &mp);
     223      }
     224
     225      /* place mbuf on freeq */
     226      rtems_interrupt_disable(level);
     227      IF_ENQUEUE(&sc->sc_freeq, mp);
     228      rtems_interrupt_enable(level);
     229      mp = (struct mbuf *)0;
     230
     231      /* release the network semaphore */
     232      rtems_bsdnet_semaphore_release();
     233
     234      /* check to see if queue is empty */
     235      if ( sc->sc_rawq.ifq_head ) {
     236        /* queue is not empty - post another event */
     237        rtems_event_send(sc->sc_rxtask, RX_PACKET);
     238      }
     239    }
     240  }
     241}
     242
     243static rtems_task ppp_txdaemon(rtems_task_argument arg)
     244{
     245  rtems_event_set             events;
     246  char                        cFrame   = (char              )PPP_FLAG;
     247  int                         iprocess = (int               )0;
     248  struct ppp_softc           *sc       = (struct ppp_softc *)arg;
     249  struct mbuf                *mp;
     250  struct mbuf                *mf;
     251  struct mbuf                *m;
     252  struct rtems_termios_tty   *tp;
     253
     254  /* enter processing loop */
     255  while ( 1 ) {
     256    /* wait for event */
     257    rtems_event_receive(TX_PACKET|TX_TRANSMIT,RTEMS_WAIT|RTEMS_EVENT_ANY,RTEMS_NO_TIMEOUT,&events);
     258    if ( events & TX_TRANSMIT ) {
     259      /* received event from interrupt handler - free current mbuf */
     260      rtems_bsdnet_semaphore_obtain();
     261      m_freem(sc->sc_outm);
     262      rtems_bsdnet_semaphore_release();
     263
     264      /* chain is done - clear the values */
     265      sc->sc_outm  = (struct mbuf *)0;
     266      sc->sc_outmc = (struct mbuf *)0;
     267
     268      /* now set flag to fake receive of TX_PACKET event */
     269      /* this will check to see if we have any pending packets */
     270      events |= TX_PACKET;
     271    }
     272
     273    /* received event from pppasyncstart */
     274    if ( events & TX_PACKET ) {
     275      /* ensure we are not busy */
     276      if ( sc->sc_outm == (struct mbuf *)0 ) {
     277        /* try dequeuing a packet */
     278        sc->sc_outm = ppp_dequeue(sc);
     279        if ( sc->sc_outm == NULL ) {
     280          /* clear output flags */
     281          sc->sc_outflag      = 0;
     282          sc->sc_if.if_flags &= ~IFF_OACTIVE;
     283        }
     284        else {
     285          /* set flag to start process */
     286          iprocess            = 1;
     287          sc->sc_outflag      = SC_TX_BUSY;
     288          sc->sc_if.if_flags |= IFF_OACTIVE;
     289        }
     290      }
     291    }
     292
     293    /* check to see if there is any processing required */
     294    if ( iprocess ) {
     295      /* clear process flag */
     296      iprocess = (int)0;
     297
     298      /* initialize output values */
     299      sc->sc_outfcs    = PPP_INITFCS;
     300      sc->sc_outbuf    = (u_char *)0;
     301      sc->sc_outlen    = (short   )0;
     302      sc->sc_outoff    = (short   )0;
     303      sc->sc_outfcslen = (short   )0;
     304
     305      /* loop over all mbufs in chain */
     306      mf     = NULL;
     307      mp     = NULL;
     308      m      = sc->sc_outm;
     309      while (( m != (struct mbuf *)0 ) && ( m->m_len > 0 )) {
     310        /* check to see if first mbuf value has been set */
     311        if ( sc->sc_outmc == (struct mbuf *)0 ) {
     312          /* set values to start with this mbuf */
     313          sc->sc_outmc  = m;
     314          sc->sc_outlen = m->m_len;
     315          sc->sc_outbuf = mtod(m, u_char *);
     316        }
     317
     318        /* update the FCS value and then check next packet length */
     319        sc->sc_outfcs = pppfcs(sc->sc_outfcs, mtod(m, u_char *), m->m_len);
     320
     321        /* check next packet to see if it is empty */
     322        while (( m->m_next != NULL ) && ( m->m_next->m_len == 0 )) {
     323          /* next mbuf is zero length */
     324          /* add empty mbuf to free chain */
     325          if ( mp == NULL ) {
     326            /* item is head of free list */
     327            mf = m->m_next;
     328            mp = mf;
     329          }
     330          else {
     331            /* add item to end of the free list */
     332            mp->m_next = m->m_next;
     333            mp         = m->m_next;
     334          }
     335
     336          /* remove empty item from process chain */
     337          m->m_next  = m->m_next->m_next;
     338          mp->m_next = NULL;
     339        }
     340
     341        /* move to next packet */
     342        m = m->m_next;
     343      }
     344
     345      /* ensure there is data to be sent out */
     346      tp = (struct rtems_termios_tty *)sc->sc_devp;
     347      if (( tp != NULL ) && ( sc->sc_outmc != (struct mbuf *)0 )) {
     348        /* place FCS value into buffer */
     349        sc->sc_outfcsbuf[sc->sc_outfcslen++] = ~sc->sc_outfcs & 0xff;
     350        sc->sc_outfcsbuf[sc->sc_outfcslen++] = (~sc->sc_outfcs >> 8) & 0xff;
     351        microtime(&sc->sc_if.if_lastchange);
     352 
     353        /* write out frame byte to start the transmission */
     354        (*tp->device.write)(tp->minor, &cFrame, 1);
     355      }
     356
     357      /* check to see if we need to free some empty mbufs */
     358      if ( mf != (struct mbuf *)0 ) {
     359        /* free empty mbufs */
     360        rtems_bsdnet_semaphore_obtain();
     361        m_freem(mf);
     362        rtems_bsdnet_semaphore_release();
     363      }
     364    }
     365  }
     366}
     367
     368static void ppp_init(struct ppp_softc *sc)
     369{
     370  rtems_status_code   status;
     371  rtems_unsigned32    priority = 100;
     372
     373  /* determine priority value */
     374  if ( rtems_bsdnet_config.network_task_priority ) {
     375    priority = rtems_bsdnet_config.network_task_priority;
     376  }
     377
     378  /* check to see if we need to start up daemons */
     379  if ( sc->sc_rxtask == 0 ) {
     380    /* start rx daemon task */
     381    status = rtems_task_create(rtems_build_name('R','x','P','0'), priority, 2048,
     382                               RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
     383                               RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
     384                               &sc->sc_rxtask);
     385    if (status != RTEMS_SUCCESSFUL) {
     386      rtems_fatal_error_occurred(status);
     387    }
     388    else {
     389      status = rtems_task_start(sc->sc_rxtask, ppp_rxdaemon, (rtems_task_argument)sc);
     390      if (status != RTEMS_SUCCESSFUL) {
     391        rtems_fatal_error_occurred(status);
     392      }
     393    }
     394
     395    /* start tx daemon task */
     396    status = rtems_task_create(rtems_build_name('T','x','P','0'), priority, 2048,
     397                               RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0),
     398                               RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
     399                               &sc->sc_txtask);
     400    if (status != RTEMS_SUCCESSFUL) {
     401      rtems_fatal_error_occurred(status);
     402    }
     403    else {
     404      status = rtems_task_start(sc->sc_txtask, ppp_txdaemon, (rtems_task_argument)sc);
     405      if (status != RTEMS_SUCCESSFUL) {
     406        rtems_fatal_error_occurred(status);
     407      }
     408    }
     409  }
     410
     411  /* mark driver running and output inactive */
     412  sc->sc_if.if_flags |= IFF_RUNNING;
     413}
    189414
    190415/*
    191416 * Called from boot code to establish ppp interfaces.
    192417 */
    193 int rtems_ppp_driver_attach (struct rtems_bsdnet_ifconfig *config,
    194                              int attaching)
     418int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching)
    195419{
    196     register struct ppp_softc *sc;
    197     register int i = 0;
    198 /*  XXX unused in rtems
    199     extern void (*netisrs[])__P((void)); */
     420    int                 i = (int)0;
     421    struct ppp_softc   *sc;
    200422
    201423    for (sc = ppp_softc; i < NPPP; sc++) {
     
    212434        sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN;
    213435        sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN;
     436        sc->sc_freeq.ifq_maxlen = NUM_MBUFQ;
     437
     438        /* initialize and attach */
     439        ppp_init(sc);
    214440        if_attach(&sc->sc_if);
    215441#if NBPFILTER > 0
     
    217443#endif
    218444    }
    219 /* hardcoded in rtems_glue.c
    220     netisrs[NETISR_PPP] = pppintr; */
    221         return 1;
     445
     446    return ( 1 );
    222447}
    223448
     
    231456    int nppp, i;
    232457    struct ppp_softc *sc;
     458
    233459    for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++)
    234460        if (sc->sc_xfer == pid) {
     
    247473    bzero((char *)&sc->sc_stats, sizeof(sc->sc_stats));
    248474#ifdef VJC
    249     sc->sc_comp=malloc(sizeof(struct vjcompress),M_DEVBUF, M_NOWAIT);
     475    MALLOC(sc->sc_comp, struct vjcompress *, sizeof(struct vjcompress),
     476           M_DEVBUF, M_NOWAIT);
    250477    if (sc->sc_comp)
    251478        vj_compress_init(sc->sc_comp, -1);
     
    259486    sc->sc_npqueue = NULL;
    260487    sc->sc_npqtail = &sc->sc_npqueue;
    261         microtime(&ppp_time);
     488    microtime(&ppp_time);
    262489    sc->sc_last_sent = sc->sc_last_recv = ppp_time.tv_sec;
    263490
     
    273500{
    274501    struct mbuf *m;
     502    rtems_interrupt_level       level;
    275503
    276504    if_down(&sc->sc_if);
     
    278506    sc->sc_devp = NULL;
    279507    sc->sc_xfer = 0;
    280     for (;;) {
    281         IF_DEQUEUE(&sc->sc_rawq, m);
    282         if (m == NULL)
    283             break;
    284         m_freem(m);
    285     }
     508
     509    rtems_interrupt_disable(level);
     510    if ( sc->sc_m != NULL ) {
     511        m_freem(sc->sc_m);
     512        sc->sc_m = (struct mbuf *)0;
     513    }
     514    if ( sc->sc_outm != NULL ) {
     515        m_freem(sc->sc_outm);
     516        sc->sc_outm    = (struct mbuf *)0;
     517        sc->sc_outmc   = (struct mbuf *)0;
     518        sc->sc_outflag = 0;
     519    }
     520    do {
     521      IF_DEQUEUE(&sc->sc_freeq, m);
     522      if (m != NULL) {
     523        m_freem(m);
     524      }
     525    } while ( m != NULL );
     526    do {
     527      IF_DEQUEUE(&sc->sc_rawq, m);
     528      if (m != NULL) {
     529        m_freem(m);
     530      }
     531    } while ( m != NULL );
     532    rtems_interrupt_enable(level);
     533
    286534    for (;;) {
    287535        IF_DEQUEUE(&sc->sc_inq, m);
     
    299547        sc->sc_npqueue = m->m_nextpkt;
    300548        m_freem(m);
    301     }
    302     if (sc->sc_togo != NULL) {
    303         m_freem(sc->sc_togo);
    304         sc->sc_togo = NULL;
    305549    }
    306550#ifdef PPP_COMPRESS
     
    311555#ifdef PPP_FILTER
    312556    if (sc->sc_pass_filt.bf_insns != 0) {
    313         free(sc->sc_pass_filt.bf_insns, M_DEVBUF);
     557        FREE(sc->sc_pass_filt.bf_insns, M_DEVBUF);
    314558        sc->sc_pass_filt.bf_insns = 0;
    315559        sc->sc_pass_filt.bf_len = 0;
    316560    }
    317561    if (sc->sc_active_filt.bf_insns != 0) {
    318         free(sc->sc_active_filt.bf_insns, M_DEVBUF);
     562        FREE(sc->sc_active_filt.bf_insns, M_DEVBUF);
    319563        sc->sc_active_filt.bf_insns = 0;
    320564        sc->sc_active_filt.bf_len = 0;
     
    323567#ifdef VJC
    324568    if (sc->sc_comp != 0) {
    325         free(sc->sc_comp, M_DEVBUF);
     569        FREE(sc->sc_comp, M_DEVBUF);
    326570        sc->sc_comp = 0;
    327571    }
     
    340584    struct proc *p;
    341585{
    342     int s, flags, mru, npx;
     586    int s, flags, mru, npx, taskid;
    343587    struct npioctl *npi;
    344588    time_t t;
     
    361605        break;
    362606
     607    case PPPIOCSTASK:
     608        taskid = *(int *)data;
     609        sc->sc_pppdtask = taskid;
     610        break;
     611
    363612    case PPPIOCGUNIT:
    364613        *(int *)data = sc->sc_if.if_unit;
     
    383632    case PPPIOCSMRU:
    384633        mru = *(int *)data;
    385         if (mru >= PPP_MRU && mru <= PPP_MAXMRU)
    386             sc->sc_mru = mru;
     634        if ( mru >= MCLBYTES ) {
     635          /* error - currently only handle 1 culster sized MRU */
     636          /* if we want to handle up to PPP_MAXMRU then we */
     637          /*   need to reallocate all mbufs on the freeq */
     638          /*   this can only be done with iterrupts disabled */
     639          return ( -1 );
     640        }
     641        else if ( mru >= PPP_MRU ) {
     642          /* update the size */
     643          sc->sc_mru = mru;
     644        }
    387645        break;
    388646
     
    489747    case PPPIOCGIDLE:
    490748        s = splsoftnet();
    491         microtime(&ppp_time);
     749        microtime(&ppp_time);
    492750        t = ppp_time.tv_sec;
    493751        ((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent;
     
    504762        newcodelen = nbp->bf_len * sizeof(struct bpf_insn);
    505763        if (newcodelen != 0) {
    506             newcode=(struct bpf_insn *) malloc (newcodelen, M_DEVBUF, M_WAITOK);
     764            MALLOC(newcode, struct bpf_insn *, newcodelen, M_DEVBUF, M_WAITOK);
    507765            if (newcode == 0) {
    508766                return EINVAL;          /* or sumpin */
     
    510768            if ((error = copyin((caddr_t)nbp->bf_insns, (caddr_t)newcode,
    511769                               newcodelen)) != 0) {
    512                 free(newcode, M_DEVBUF);
     770                FREE(newcode, M_DEVBUF);
    513771                return error;
    514772            }
    515773            if (!bpf_validate(newcode, nbp->bf_len)) {
    516                 free(newcode, M_DEVBUF);
     774                FREE(newcode, M_DEVBUF);
    517775                return EINVAL;
    518776            }
     
    526784        splx(s);
    527785        if (oldcode != 0)
    528             free(oldcode, M_DEVBUF);
     786            FREE(oldcode, M_DEVBUF);
    529787        break;
    530788#endif
     
    545803    caddr_t data;
    546804{
    547 /*    struct proc *p = curproc; *//* XXX */
     805    /*struct proc *p = curproc;*/       /* XXX */
    548806    register struct ppp_softc *sc = &ppp_softc[ifp->if_unit];
    549807    register struct ifaddr *ifa = (struct ifaddr *)data;
     
    595853        }
    596854        break;
    597         case SIO_RTEMS_SHOW_STATS:
    598   printf ("              MRU:%-8lu", sc->sc_mru);
    599   printf ("   Bytes received:%-8lu", sc->sc_stats.ppp_ibytes);
    600   printf (" Packets received:%-8lu", sc->sc_stats.ppp_ipackets);
    601   printf ("   Receive errors:%-8lu\n", sc->sc_stats.ppp_ierrors);
    602   printf ("       Bytes sent:%-8lu", sc->sc_stats.ppp_obytes);
    603   printf ("     Packets sent:%-8lu", sc->sc_stats.ppp_opackets);
    604   printf ("  Transmit errors:%-8lu\n", sc->sc_stats.ppp_oerrors);
    605        
    606         break;
    607        
     855
     856    case SIO_RTEMS_SHOW_STATS:
     857        printf("              MRU:%-8u",   sc->sc_mru);
     858        printf("   Bytes received:%-8u",   sc->sc_stats.ppp_ibytes);
     859        printf(" Packets received:%-8u",   sc->sc_stats.ppp_ipackets);
     860        printf("   Receive errors:%-8u\n", sc->sc_stats.ppp_ierrors);
     861        printf("       Bytes sent:%-8u",   sc->sc_stats.ppp_obytes);
     862        printf("     Packets sent:%-8u",   sc->sc_stats.ppp_opackets);
     863        printf("  Transmit errors:%-8u\n", sc->sc_stats.ppp_oerrors);
     864        break;
    608865
    609866    case SIOCGPPPSTATS:
     
    663920    int len;
    664921    struct mbuf *m;
     922
    665923    if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0
    666924        || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) {
     
    7631021        if (sc->sc_active_filt.bf_insns == 0
    7641022            || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m0, len, 0))
    765             {
    766                 microtime(&ppp_time);
    767                 sc->sc_last_sent = ppp_time.tv_sec;
    768             }
     1023            sc->sc_last_sent = time.tv_sec;
    7691024
    7701025        *mtod(m0, u_char *) = address;
     
    7731028         * Update the time we sent the most recent data packet.
    7741029         */
    775         microtime(&ppp_time);
     1030        microtime(&ppp_time);
    7761031        sc->sc_last_sent = ppp_time.tv_sec;
    7771032#endif /* PPP_FILTER */
     
    7891044     * Put the packet on the appropriate queue.
    7901045     */
     1046    s = splsoftnet();
    7911047    if (mode == NPMODE_QUEUE) {
    7921048        /* XXX we should limit the number of packets on this queue */
     
    8071063        (*sc->sc_start)(sc);
    8081064    }
    809         microtime(&ppp_time);
    8101065    ifp->if_lastchange = ppp_time;
    8111066    ifp->if_opackets++;
    8121067    ifp->if_obytes += len;
    8131068
     1069    splx(s);
    8141070    return (0);
    8151071
     
    8721128
    8731129/*
    874  * Transmitter has finished outputting some stuff;
    875  * remember to call sc->sc_start later at splsoftnet.
    876  */
    877 void
    878 ppp_restart(sc)
    879     struct ppp_softc *sc;
    880 {
    881 
    882     sc->sc_flags &= ~SC_TBUSY;
    883 /*    schednetisr(NETISR_PPP);
    884 */}
    885 
    886 /*
    8871130 * Get a packet to send.  This procedure is intended to be called at
    8881131 * splsoftnet, since it may involve time-consuming operations such as
     
    9021145     * normal queue.
    9031146     */
     1147    rtems_bsdnet_semaphore_obtain();
    9041148    IF_DEQUEUE(&sc->sc_fastq, m);
    9051149    if (m == NULL)
    9061150        IF_DEQUEUE(&sc->sc_if.if_snd, m);
     1151    rtems_bsdnet_semaphore_release();
     1152
    9071153    if (m == NULL)
    9081154        return NULL;
     
    10191265 */
    10201266void
    1021 pppintr()
     1267pppintr(void)
    10221268{
    1023     struct ppp_softc *sc;
    1024     int i, s2;
    1025     struct mbuf *m;
    1026 
    1027     sc = ppp_softc;
    1028     for (i = 0; i < NPPP; ++i, ++sc) {
    1029         if (!(sc->sc_flags & SC_TBUSY)
    1030             && (sc->sc_if.if_snd.ifq_head || sc->sc_fastq.ifq_head)) {
    1031             s2 = splimp();
    1032             sc->sc_flags |= SC_TBUSY;
    1033             splx(s2);
    1034             (*sc->sc_start)(sc);
    1035         }
    1036         for (;;) {
    1037             IF_DEQUEUE(&sc->sc_rawq, m);
    1038             if (m == NULL)
    1039                 break;
    1040             ppp_inproc(sc, m);
    1041         }
    1042     }
    10431269}
    10441270
     
    11611387
    11621388/*
    1163  * PPP packet input routine.
    1164  * The caller has checked and removed the FCS and has inserted
    1165  * the address/control bytes and the protocol high byte if they
    1166  * were omitted.
    1167  */
    1168 void
    1169 ppppktin(sc, m, lost)
    1170     struct ppp_softc *sc;
    1171     struct mbuf *m;
    1172     int lost;
    1173 {
    1174 
    1175     if (lost)
    1176         m->m_flags |= M_ERRMARK;
    1177     IF_ENQUEUE(&sc->sc_rawq, m);
    1178     pppintr();
    1179 }
    1180 
    1181 /*
    11821389 * Process a received PPP packet, doing decompression as necessary.
    11831390 * Should be called at splsoftnet.
     
    11861393                         TYPE_UNCOMPRESSED_TCP)
    11871394
    1188 static void
     1395static struct mbuf *
    11891396ppp_inproc(sc, m)
    11901397    struct ppp_softc *sc;
    11911398    struct mbuf *m;
    11921399{
     1400    struct mbuf  *mf = (struct mbuf *)0;
    11931401    struct ifnet *ifp = &sc->sc_if;
    11941402    struct ifqueue *inq;
    1195     int s, ilen, xlen, proto, rv;
     1403    int s, ilen, xlen, proto, rv; 
    11961404    u_char *cp, adrs, ctrl;
    11971405    struct mbuf *mp;
    11981406#ifdef PPP_COMPRESS
    1199     *dmp = NULL;
     1407    struct mbuf *dmp = NULL;
    12001408#endif
    12011409    u_char *iphdr;
     
    12371445            if (dmp == NULL) {
    12381446                /* no error, but no decompressed packet produced */
    1239                 return;
     1447                return mf;
    12401448            }
    12411449            m = dmp;
     
    13701578        if (mp != NULL) {
    13711579            m_copydata(m, 0, ilen, mtod(mp, caddr_t));
    1372             m_freem(m);
     1580            /* instead of freeing - return cluster mbuf so it can be reused */
     1581            /* m_freem(m); */
     1582            mf = m;
    13731583            m = mp;
    13741584            m->m_len = ilen;
     
    13911601            /* drop this packet */
    13921602            m_freem(m);
    1393             return;
     1603            return mf;
    13941604        }
    13951605        if (sc->sc_active_filt.bf_insns == 0
    13961606            || bpf_filter(sc->sc_active_filt.bf_insns, (u_char *) m, ilen, 0))
    1397             {
    1398                 microtime(&ppp_time);
    1399 
    1400                 sc->sc_last_recv = ppp_time.tv_sec;
    1401             }
     1607            sc->sc_last_recv = time.tv_sec;
    14021608
    14031609        *mtod(m, u_char *) = adrs;
     
    14281634            /* interface is down - drop the packet. */
    14291635            m_freem(m);
    1430             return;
     1636            return mf;
    14311637        }
    14321638        m->m_pkthdr.len -= PPP_HDRLEN;
     
    14611667    IF_ENQUEUE(inq, m);
    14621668    splx(s);
     1669
    14631670    ifp->if_ipackets++;
    14641671    ifp->if_ibytes += ilen;
    1465         microtime(&ppp_time);
     1672    microtime(&ppp_time);
    14661673    ifp->if_lastchange = ppp_time;
    14671674
    1468     if (rv)
    1469         (*sc->sc_ctlp)(sc);
    1470 
    1471     return;
     1675    if (rv) {
     1676      (*sc->sc_ctlp)(sc);
     1677    }
     1678
     1679    return mf;
    14721680
    14731681 bad:
     
    14751683    sc->sc_if.if_ierrors++;
    14761684    sc->sc_stats.ppp_ierrors++;
     1685    return mf;
    14771686}
    14781687
  • c/src/libnetworking/net/if_ppp.h

    rd8a78f4f r0286b9f  
    3939#define SC_LOG_RAWIN    0x00080000      /* log all chars received */
    4040#define SC_LOG_FLUSH    0x00100000      /* log all chars flushed */
    41 #define SC_SYNC         0x00200000      /* synchrounous HDLC */
    4241#define SC_RCV_B7_0     0x01000000      /* have rcvd char with bit 7 = 0 */
    4342#define SC_RCV_B7_1     0x02000000      /* have rcvd char with bit 7 = 1 */
    4443#define SC_RCV_EVNP     0x04000000      /* have rcvd char with even parity */
    4544#define SC_RCV_ODDP     0x08000000      /* have rcvd char with odd parity */
     45#define SC_SYNC         0x00200000      /* use synchronous HDLC framing */
    4646#define SC_MASK         0x0fff00ff      /* bits that user can change */
    4747
     
    9090 */
    9191
     92#define PPPIOCSTASK     _IOW('t', 91, int)      /* set pppd task id */
    9293#define PPPIOCGFLAGS    _IOR('t', 90, int)      /* get configuration flags */
    9394#define PPPIOCSFLAGS    _IOW('t', 89, int)      /* set configuration flags */
  • c/src/libnetworking/net/if_pppvar.h

    rd8a78f4f r0286b9f  
    4646 * indexing sc_npmode.
    4747 */
    48 #define NP_IP   0               /* Internet Protocol */
    49 #define NUM_NP  1               /* Number of NPs. */
     48#define NP_IP                 0 /* Internet Protocol */
     49#define NUM_NP                1 /* Number of NPs. */
     50#define NUM_MBUFQ            64
     51
    5052
    5153/*
     
    6466        struct  ifqueue sc_inq;         /* queue of input packets for daemon */
    6567        struct  ifqueue sc_fastq;       /* interactive output packet q */
    66         struct  mbuf *sc_togo;          /* output packet ready to go */
    6768        struct  mbuf *sc_npqueue;       /* output packets not to be sent yet */
    6869        struct  mbuf **sc_npqtail;      /* ptr to last next ptr in npqueue */
     
    8586
    8687        /* Device-dependent part for async lines. */
    87         ext_accm sc_asyncmap;           /* async control character map */
    88         u_long  sc_rasyncmap;           /* receive async control char map */
    89         struct  mbuf *sc_outm;          /* mbuf chain currently being output */
    90         struct  mbuf *sc_m;             /* pointer to input mbuf chain */
    91         struct  mbuf *sc_mc;            /* pointer to current input mbuf */
    92         char    *sc_mp;                 /* ptr to next char in input mbuf */
    93         short   sc_ilen;                /* length of input packet so far */
    94         u_short sc_fcs;                 /* FCS so far (input) */
    95         u_short sc_outfcs;              /* FCS so far for output packet */
    96         u_char  sc_rawin[16];           /* chars as received */
    97         int     sc_rawin_count;         /* # in sc_rawin */
    98         rtems_id sem_id;                /* ID of comm semaphore         */
     88        ext_accm sc_asyncmap;                /* async control character map */
     89        u_long  sc_rasyncmap;                /* receive async control char map */
     90        struct  mbuf *sc_outm;               /* mbuf chain currently being output */
     91        struct  mbuf *sc_outmc;              /* mbuf currently being output */
     92        struct  mbuf *sc_m;                  /* pointer to input mbuf chain */
     93        struct  mbuf *sc_mc;                 /* pointer to current input mbuf */
     94        char    *sc_mp;                      /* ptr to next char in input mbuf */
     95        short   sc_ilen;                     /* length of input packet so far */
     96        u_short sc_fcs;                      /* FCS so far (input) */
     97        u_char  sc_rawin[16];                /* chars as received */
     98        int     sc_rawin_count;              /* # in sc_rawin */
     99        u_short sc_outfcs;                   /* FCS so far for output packet */
     100
     101        struct  ifqueue sc_freeq;            /* free packets */
     102        short   sc_outoff;                   /* output packet byte offset */
     103        short   sc_outflag;                  /* output status flag */
     104        short   sc_outlen;                   /* length of output packet */
     105        short   sc_outfcslen;                /* length of output fcs data */
     106        u_char  sc_outfcsbuf[8];             /* output packet fcs buffer */
     107        u_char *sc_outbuf;                   /* pointer to output data */
     108
     109        rtems_id sc_rxtask;
     110        rtems_id sc_txtask;
     111        rtems_id sc_pppdtask;
    99112};
    100113
     
    107120int     pppioctl __P((struct ppp_softc *sc, int cmd, caddr_t data,
    108121                      int flag, struct proc *p));
    109 void    ppp_restart __P((struct ppp_softc *sc));
    110 void    ppppktin __P((struct ppp_softc *sc, struct mbuf *m, int lost));
    111122struct  mbuf *ppp_dequeue __P((struct ppp_softc *sc));
     123u_short pppfcs __P((u_short fcs, u_char *cp, int len));
     124void    pppallocmbuf __P((struct ppp_softc *sc, struct mbuf **mp));
     125
     126
     127/* define event values */
     128#define RX_PACKET    RTEMS_EVENT_1
     129#define RX_MBUF      RTEMS_EVENT_2
     130#define RX_EMPTY     RTEMS_EVENT_3
     131#define TX_PACKET    RTEMS_EVENT_1
     132#define TX_TRANSMIT  RTEMS_EVENT_2
     133#define PPPD_EVENT   RTEMS_EVENT_31
     134
     135/* define out flag values */
     136#define SC_TX_BUSY      0x0001
     137#define SC_TX_FCS       0x0002
     138#define SC_TX_ESCAPE    0x0004
     139#define SC_TX_PENDING   0x0010
  • c/src/libnetworking/net/ppp-comp.h

    rd8a78f4f r0286b9f  
    3636 */
    3737#ifndef DO_BSD_COMPRESS
    38 #define DO_BSD_COMPRESS 1       /* by default, include BSD-Compress */
     38#define DO_BSD_COMPRESS 0       /* by default, include BSD-Compress */
    3939#endif
    4040#ifndef DO_DEFLATE
    41 #define DO_DEFLATE      1       /* by default, include Deflate */
     41#define DO_DEFLATE      0       /* by default, include Deflate */
    4242#endif
    4343#define DO_PREDICTOR_1  0
  • c/src/libnetworking/net/ppp_defs.h

    rd8a78f4f r0286b9f  
    7878#define PPP_ATCP        0x8029  /* AppleTalk Control Protocol */
    7979#define PPP_IPXCP       0x802b  /* IPX Control Protocol */
     80#define PPP_IPV6CP      0x8057  /* IPv6 Control Protocol */
    8081#define PPP_CCP         0x80fd  /* Compression Control Protocol */
    8182#define PPP_LCP         0xc021  /* Link Control Protocol */
     
    9798
    9899#if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) \
    99  && !defined(__FreeBSD__) && (NS_TARGET < 40) && !defined(__rtems__)
     100 && !defined(__FreeBSD__) && (NS_TARGET < 40)
    100101#ifdef  UINT32_T
    101102typedef UINT32_T        u_int32_t;
    102103#else
    103 typedef unsigned int    u_int32_t;
    104 typedef unsigned short  u_int16_t;
     104/*typedef unsigned int  u_int32_t;*/
     105/*typedef unsigned short  u_int16_t;*/
    105106#endif
    106107#endif
  • c/src/libnetworking/pppd/Makefile.am

    rd8a78f4f r0286b9f  
    1111LIB = $(ARCH)/$(LIBNAME)
    1212
    13 C_FILES = auth.c ccp.c chap.c chap_ms.c chat.c demand.c fsm.c ipcp.c lcp.c magic.c options.c upap.c md4.c md5.c utils.c sys-rtems.c rtemsmain.c rtemspppd.c
     13C_FILES = auth.c ccp.c chap.c chap_ms.c chat.c demand.c fsm.c ipcp.c lcp.c \
     14    magic.c options.c upap.c md4.c md5.c utils.c sys-rtems.c rtemsmain.c \
     15    rtemspppd.c
    1416C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)
    1517
     
    3436chat.c demand.c fsm.c fsm.h ipcp.c ipcp.h ipxcp.c ipxcp.h \
    3537lcp.c lcp.h magic.c magic.h md4.c md4.h md5.c md5.h options.c \
    36 patchlevel.h pathnames.h pppd.h rtemsmain.c rtemspppd.c rtemspppd.h \
    37 sys-rtems.c upap.c upap.h utils.c
     38patchlevel.h pathnames.h pppd.h rtemsdialer.h rtemsmain.c rtemspppd.c \
     39rtemspppd.h sys-rtems.c upap.c upap.h utils.c
    3840
    39 include_HEADERS = rtemspppd.h
     41include_HEADERS = rtemspppd.h rtemsdialer.h
    4042
    4143
  • c/src/libnetworking/pppd/README

    rd8a78f4f r0286b9f  
    2121the ABORT commands.  Removed some dead code and did a lot of
    2222testing on a new Coldfire BSP.  Version seems to be very stable.
     23
     24Update code to use RTEMS pppd network drivers.  Now the pppd
     25software is not dependent on using task driven mode.  This
     26change improved stablity and performance.  This was updated
     27by Mike Siers <mikes@poliac.com>.
    2328=================================================================
    2429
  • c/src/libnetworking/pppd/STATUS

    rd8a78f4f r0286b9f  
    1717with this function call.
    1818
    19 The pppd application requires the BSP termios driver support task
    20 driven I/O.  Below is a list of known issues that need to be resolved:
    21 
    22   - pppd locks up when it receives large packet pings (> 1500 bytes)
    23   - pppd occasionaly locks up with mbuf allocation error
    24     (problem is rare and may be BSP related)
     19The pppd code had now been updated to use it's own RTEMS network
     20drivers.  This removes the requirement for the task driven termios
     21support.  This update has fixed the large packet ping problem.
     22Currently, I do not know of any problems with the port.
    2523
    2624If you find any other problems or fix some problems, please post your
  • c/src/libnetworking/pppd/chap.h

    rd8a78f4f r0286b9f  
    111111 * Timeouts.
    112112 */
    113 #define CHAP_DEFTIMEOUT         3       /* Timeout time in seconds */
     113#define CHAP_DEFTIMEOUT         5       /* Timeout time in seconds */
    114114#define CHAP_DEFTRANSMITS       10      /* max # times to send challenge */
    115115
  • c/src/libnetworking/pppd/chat.c

    rd8a78f4f r0286b9f  
    157157char *phone_num      = (char *) 0;
    158158char *phone_num2     = (char *) 0;
     159static int ttyfd;
    159160static int timeout   = DEFAULT_CHAT_TIMEOUT;
    160161
     
    193194char *clean __P((register char *s, int sending));
    194195char *expect_strtok __P((char *, char *));
    195 int chatmain __P((char *));
     196int chatmain __P((int, int, char *));
    196197
    197198
     
    225226}
    226227
    227 int chatmain(argv)
    228 char *argv;
     228int chatmain(int fd, int mode, char *pScript)
    229229{
    230230  char    *arg;
     
    232232  /* initialize exit code */
    233233  exit_code = 0;
     234  ttyfd     = fd;
    234235
    235236  if ( debug ) {
    236     dbglog("chat_main: %s\n", argv);
     237    dbglog("chat_main: %s\n", pScript);
    237238  }
    238239
    239240  /* get first expect string */
    240   arg = getnextcommand(&argv);
     241  arg = getnextcommand(&pScript);
    241242  while (( arg != NULL ) && ( exit_code == 0 )) {
    242243    /* process the expect string */
     
    244245    if ( exit_code == 0 ) {
    245246      /* get the next send string */
    246       arg = getnextcommand(&argv);
     247      arg = getnextcommand(&pScript);
    247248      if ( arg != NULL ) {
    248249        /* process the send string */
     
    250251
    251252        /* get the next expect string */
    252         arg = getnextcommand(&argv);
     253        arg = getnextcommand(&pScript);
    253254      }
    254255    }
    255256  }
    256 
    257   if ( exit_code ) {
    258    exit_code = -exit_code;
    259   }
     257  ttyfd = (int)-1;
    260258
    261259  return ( exit_code );
  • c/src/libnetworking/pppd/example/netconfig.h

    rd8a78f4f r0286b9f  
    66
    77/* external function prototypes */
    8 extern int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config,
    9                                    int attaching);
     8extern int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching);
    109
    1110/* Default network interface */
     
    1413  rtems_ppp_driver_attach,   /* attach function */
    1514  NULL,                      /* No more interfaces */
    16   "192.168.2.123",           /* IP address */
    17   "255.255.255.0",           /* IP net mask */
     15  NULL,                      /* IP address */
     16  NULL,                      /* IP net mask */
    1817  NULL,                      /* Driver supplies hardware address */
    1918  0                          /* Use default driver parameters */
     
    2423  &netdriver_config,
    2524  NULL,
    26   0,                  /* Default network task priority */
    27   0,                  /* Default mbuf capacity */
    28   0,                  /* Default mbuf cluster capacity */
    29   "rtems",            /* Host name */
    30   "xxxyyy.com",       /* Domain name */
     25  30,                 /* Default network task priority */
     26  (256*1024),         /* Default mbuf capacity */
     27  (512*1024),         /* Default mbuf cluster capacity */
     28  0,                  /* Host name */
     29  0,                  /* Domain name */
    3130  0,                  /* Gateway */
    3231  0,                  /* Log host */
  • c/src/libnetworking/pppd/fsm.c

    rd8a78f4f r0286b9f  
    6060    f->state = INITIAL;
    6161    f->flags = 0;
    62     f->id = 0;                          /* XXX Start with random id? */
     62    f->id = 100;                /* XXX Start with random id? */
    6363    f->timeouttime = DEFTIMEOUT;
    6464    f->maxconfreqtransmits = DEFMAXCONFREQS;
     
    414414            if (f->callbacks->up)
    415415                (*f->callbacks->up)(f); /* Inform upper layers */
    416         } else
     416        } else {
    417417            f->state = ACKSENT;
     418            ppp_delay();
     419        }
    418420        f->nakloops = 0;
    419421
  • c/src/libnetworking/pppd/fsm.h

    rd8a78f4f r0286b9f  
    120120 * Timeouts.
    121121 */
    122 #define DEFTIMEOUT      3       /* Timeout time in seconds */
     122#define DEFTIMEOUT      5       /* Timeout time in seconds */
    123123#define DEFMAXTERMREQS  2       /* Maximum Terminate-Request transmissions */
    124124#define DEFMAXCONFREQS  10      /* Maximum Configure-Request transmissions */
  • c/src/libnetworking/pppd/ipcp.c

    rd8a78f4f r0286b9f  
    15711571    u_int32_t peerdns1, peerdns2;
    15721572{
    1573     FILE *f;
    1574 
    1575     f = fopen(_PATH_RESOLV, "w");
    1576     if (f == NULL) {
    1577         error("Failed to create %s: %m", _PATH_RESOLV);
    1578         return;
    1579     }
    1580 
    1581     if (peerdns1)
    1582         fprintf(f, "nameserver %s\n", ip_ntoa(peerdns1));
    1583 
    1584     if (peerdns2)
    1585         fprintf(f, "nameserver %s\n", ip_ntoa(peerdns2));
    1586 
    1587     if (ferror(f))
    1588         error("Write failed to %s: %m", _PATH_RESOLV);
    1589 
    1590     fclose(f);
     1573  extern int              rtems_bsdnet_nameserver_count;
     1574  extern struct in_addr   rtems_bsdnet_nameserver[];
     1575
     1576  /* initialize values */
     1577  rtems_bsdnet_nameserver_count = (int)0;
     1578
     1579  /* check to see if primary was specified */
     1580  if ( peerdns1 ) {
     1581    rtems_bsdnet_nameserver[rtems_bsdnet_nameserver_count].s_addr = peerdns1;
     1582    rtems_bsdnet_nameserver_count++;
     1583  }
     1584
     1585  /* check to see if secondary was specified */
     1586  if ( peerdns2 ) {
     1587    rtems_bsdnet_nameserver[rtems_bsdnet_nameserver_count].s_addr = peerdns2;
     1588    rtems_bsdnet_nameserver_count++;
     1589  }
     1590
     1591  /* initialize resolver */
     1592  __res_init();
    15911593}
    15921594
  • c/src/libnetworking/pppd/options.c

    rd8a78f4f r0286b9f  
    716716            if (sv == NULL)
    717717                novm("option argument");
     718            if ( *(char **)(opt->addr) != NULL ) {
     719                free((void *)*(char **)(opt->addr));
     720                *(char **)(opt->addr) = NULL;
     721            }
    718722            *(char **)(opt->addr) = sv;
    719723        }
  • c/src/libnetworking/pppd/pppd.h

    rd8a78f4f r0286b9f  
    2020 */
    2121
    22 /*
    23  * TODO:
    24  */
    25 
    2622#ifndef __PPPD_H__
    2723#define __PPPD_H__
     
    3329#include <sys/time.h>           /* for struct timeval */
    3430#include <net/ppp_defs.h>
     31#include "rtemsdialer.h"
    3532
    3633#if defined(__STDC__)
     
    168165extern int      do_callback;    /* set if we want to do callback next */
    169166extern int      doing_callback; /* set if this is a callback */
     167extern dialerfp pppd_dialer;    /* script dialer function callback */
    170168
    171169/* Values for do_callback and doing_callback */
     
    379377void setdtr __P((int, int));    /* Raise or lower port's DTR line */
    380378void output __P((int, u_char *, int)); /* Output a PPP packet */
    381 void wait_input __P((struct timeval *));
    382                                 /* Wait for input, with timeout */
     379void wait_input __P((struct timeval *)); /* Wait for input, with timeout */
     380
     381void ppp_delay __P((void));       /* delay task for a little while */
    383382int  read_packet __P((u_char *)); /* Read PPP packet */
    384383int  get_loop_output __P((void)); /* Read pkts from loopback */
  • c/src/libnetworking/pppd/rtemsmain.c

    rd8a78f4f r0286b9f  
    4242#include <rtems.h>
    4343#include <rtems/rtems_bsdnet.h>
    44 extern void rtems_bsdnet_semaphore_obtain(void);
    45 extern void rtems_bsdnet_semaphore_release(void);
    46 extern int  chatmain(char *argv);
    4744
    4845#include "pppd.h"
     
    5956#include "pathnames.h"
    6057#include "patchlevel.h"
     58#include "rtemsdialer.h"
    6159
    6260#ifdef CBCP_SUPPORT
     
    9593int doing_callback;             /* != 0 if we are doing callback */
    9694char *callback_script;          /* script for doing callback */
     95dialerfp pppd_dialer;
    9796
    9897int (*holdoff_hook) __P((void)) = NULL;
     
    130129static struct timeval *timeleft __P((struct timeval *));
    131130static void holdoff_end __P((void *));
    132 static int device_script __P((char *, int, int, int));
     131static int device_script __P((int, int, char *));
    133132
    134133extern  char    *ttyname __P((int));
     
    313312
    314313            if (initializer && initializer[0]) {
    315                 if (device_script(initializer, ttyfd, ttyfd, 0) < 0) {
     314                if (device_script(ttyfd, DIALER_INIT, initializer) < 0) {
    316315                    error("Initializer script failed");
    317316                    status = EXIT_INIT_FAILED;
     
    325324
    326325            if (connector && connector[0]) {
    327                 if (device_script(connector, ttyfd, ttyfd, 0) < 0) {
     326                if (device_script(ttyfd, DIALER_CONNECT, connector) < 0) {
    328327                    error("Connect script failed");
    329328                    status = EXIT_CONNECT_FAILED;
     
    365364        /* run welcome script, if any */
    366365        if (welcomer && welcomer[0]) {
    367             if (device_script(welcomer, ttyfd, ttyfd, 0) < 0)
     366            if (device_script(ttyfd, DIALER_WELCOME, welcomer) < 0)
    368367                warn("Welcome script failed");
    369368        }
     
    388387        gettimeofday(&start_time, NULL);
    389388
    390         rtems_bsdnet_semaphore_obtain();
    391389        lcp_lowerup(0);
    392390        lcp_open(0);            /* Start protocol */
    393         rtems_bsdnet_semaphore_release();
    394391
    395392        open_ccp_flag = 0;
     
    399396            wait_input(timeleft(&timo));
    400397            calltimeout();
    401             get_input();
     398            get_input();
    402399
    403400            if (kill_link) {
     
    436433            if (real_ttyfd >= 0)
    437434                set_up_tty(real_ttyfd, 1);
    438             if (device_script(disconnect_script, ttyfd, ttyfd, 0) < 0) {
     435            if (device_script(ttyfd, DIALER_DISCONNECT, disconnect_script) < 0) {
    439436                warn("disconnect script failed");
    440437            } else {
     
    478475
    479476    die(status);
    480     return 0;
     477    return status;
    481478}
    482479
     
    579576 */
    580577static void
    581 get_input()
     578get_input(void)
    582579{
    583580    int len, i;
     
    609606    }
    610607
    611     rtems_bsdnet_semaphore_obtain();
    612608    p += 2;                             /* Skip address and control */
    613609    GETSHORT(protocol, p);
     
    619615    if (protocol != PPP_LCP && lcp_fsm[0].state != OPENED) {
    620616        MAINDEBUG(("get_input: Received non-LCP packet when LCP not open."));
    621         rtems_bsdnet_semaphore_release();
    622617        return;
    623618    }
     
    632627        MAINDEBUG(("get_input: discarding proto 0x%x in phase %d",
    633628                   protocol, phase));
    634         rtems_bsdnet_semaphore_release();
    635629        return;
    636630    }
     
    642636        if (protp->protocol == protocol && protp->enabled_flag) {
    643637            (*protp->input)(0, p, len);
    644             rtems_bsdnet_semaphore_release();
    645638            return;
    646639        }
     
    648641            && protp->datainput != NULL) {
    649642            (*protp->datainput)(0, p, len);
    650             rtems_bsdnet_semaphore_release();
    651643            return;
    652644        }
     
    661653    }
    662654    lcp_sprotrej(0, p - PPP_HDRLEN, len + PPP_HDRLEN);
    663     rtems_bsdnet_semaphore_release();
     655
     656    return;
    664657}
    665658
     
    873866 * (e.g. to run the connector or disconnector script).
    874867 */
    875 static int
    876 device_script(program, in, out, dont_wait)
    877     char *program;
    878     int in, out;
    879     int dont_wait;
    880 {
    881     char   pScript[256];
    882 
     868static int device_script(int fd, int mode, char *program)
     869{
     870    int    iReturn = -1;
     871    char   pScript[128];
     872
     873    /* copyt script into temporary location */
    883874    strcpy(pScript, program);
    884     return chatmain(pScript);
     875
     876    /* check to see if dialer was initialized */
     877    if ( !pppd_dialer ) {
     878      /* set default dialer to chatmain */
     879      pppd_dialer = chatmain;
     880    }
     881
     882    /* check to see if dialer is set */
     883    if ( pppd_dialer ) {
     884      /* call the dialer */
     885      iReturn = (*pppd_dialer)(fd, mode, program);
     886    }
     887
     888    return ( -iReturn );
    885889}
    886890
  • c/src/libnetworking/pppd/rtemspppd.c

    rd8a78f4f r0286b9f  
    11
    22#include <rtems.h>
     3#include <rtems/rtems_bsdnet.h>
    34#include "pppd.h"
    45#include "rtemspppd.h"
     
    78/* define pppd function prototypes */
    89extern void pppasyncattach(void);
    9 extern int pppdmain(int, char **);
     10extern int  pppdmain(int, char **);
    1011
    1112/* define global variables */
    12 rtems_id rtems_pppd_taskid;
     13rtems_id                   rtems_pppd_taskid;
     14rtems_pppd_hookfunction    rtems_pppd_errorfp;
     15rtems_pppd_hookfunction    rtems_pppd_exitfp;
    1316
    1417
     
    1922  rtems_event_set     in;
    2023  rtems_event_set     out;
     24  int                 iStatus;
    2125
    2226  /* call function to setup ppp line discipline */
     
    3943        /* connect request */
    4044        /* execute the pppd main code */
    41         pppdmain(0, NULL);
     45        iStatus = pppdmain(0, NULL);
     46        if ( iStatus == EXIT_OK ) {
     47          /* check exit callback */
     48          if ( rtems_pppd_exitfp ) {
     49            (*rtems_pppd_exitfp)();
     50          }
     51        }
     52        else {
     53          /* check error callback */
     54          if ( rtems_pppd_errorfp ) {
     55            (*rtems_pppd_errorfp)();
     56          }
     57        }
    4258      }
    4359    }
     
    4561
    4662  /* terminate myself */
     63  rtems_pppd_taskid = 0;
    4764  rtems_task_delete(RTEMS_SELF);
    4865}
     
    5067int rtems_pppd_initialize(void)
    5168{
    52   int                 iReturn = (int)-1;
     69  int                 iReturn  = (int)-1;
     70  rtems_unsigned32    priority = 100;
    5371  rtems_status_code   status;
    5472  rtems_name          taskName;
    5573
     74  /* determine priority value */
     75  if ( rtems_bsdnet_config.network_task_priority ) {
     76    priority = rtems_bsdnet_config.network_task_priority;
     77  }
     78
     79  /* initialize the exit hook */
     80  rtems_pppd_exitfp = (rtems_pppd_hookfunction)0;
     81
     82  /* create the rtems task */
    5683  taskName = rtems_build_name( 'p', 'p', 'p', 'd' );
    57   status   = rtems_task_create(taskName,
    58                                RTEMS_PPPD_TASK_PRIORITY,
    59                                RTEMS_PPPD_TASK_STACK_SIZE,
    60                                RTEMS_PPPD_TASK_INITIAL_MODES,
    61                                RTEMS_DEFAULT_ATTRIBUTES,
     84  status   = rtems_task_create(taskName, priority, 8192,
     85                               (RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0)),
     86                               RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
    6287                               &rtems_pppd_taskid);
    6388  if ( status == RTEMS_SUCCESSFUL ) {
     
    115140    ip_down_hook = hookfp;
    116141    break;
     142  case RTEMS_PPPD_ERROR_HOOK:
     143    rtems_pppd_errorfp = hookfp;
     144    break;
     145  case RTEMS_PPPD_EXIT_HOOK:
     146    rtems_pppd_exitfp = hookfp;
     147    break;
    117148  default:
    118149    iReturn = (int)-1;
     
    121152
    122153  return ( iReturn );
     154}
     155
     156int rtems_pppd_set_dialer(rtems_pppd_dialerfunction dialerfp)
     157{
     158  pppd_dialer = dialerfp;
     159  return ( (int)0 );
    123160}
    124161
  • c/src/libnetworking/pppd/rtemspppd.h

    rd8a78f4f r0286b9f  
    33#define RTEMSPPPD_H
    44
    5 /* check to see if pppd task values are set */
    6 #ifndef RTEMS_PPPD_TASK_PRIORITY
    7 #define RTEMS_PPPD_TASK_PRIORITY        120
    8 #endif
    9 #ifndef RTEMS_PPPD_TASK_STACK_SIZE
    10 #define RTEMS_PPPD_TASK_STACK_SIZE      (10*1024)
    11 #endif
    12 #ifndef RTEMS_PPPD_TASK_INITIAL_MODES
    13 #define RTEMS_PPPD_TASK_INITIAL_MODES   (RTEMS_PREEMPT | \
    14                                          RTEMS_NO_TIMESLICE | \
    15                                          RTEMS_NO_ASR | \
    16                                          RTEMS_INTERRUPT_LEVEL(0))
    17 #endif
    185
    196/* define hook function identifiers */
     
    229#define RTEMS_PPPD_IPUP_HOOK        3
    2310#define RTEMS_PPPD_IPDOWN_HOOK      4
     11#define RTEMS_PPPD_ERROR_HOOK       5
     12#define RTEMS_PPPD_EXIT_HOOK        6
    2413
    2514/* define hook function pointer prototype */
    2615typedef void (*rtems_pppd_hookfunction)(void);
     16typedef int  (*rtems_pppd_dialerfunction)(int tty, int mode, char *pScript);
    2717
    2818
     
    3222int rtems_pppd_reset_options(void);
    3323int rtems_pppd_set_hook(int id, rtems_pppd_hookfunction hookfp);
     24int rtems_pppd_set_dialer(rtems_pppd_dialerfunction dialerfp);
    3425int rtems_pppd_set_option(const char *pOption, const char *pValue);
    3526int rtems_pppd_connect(void);
  • c/src/libnetworking/pppd/sys-rtems.c

    rd8a78f4f r0286b9f  
    9696
    9797
    98 void
    99 sys_serialcallback(struct termios *tty, void *arg)
    100 {
    101   rtems_event_send(rtems_pppd_taskid, RTEMS_EVENT_31);
    102 }
    103 
    10498/*
    10599 * sys_init - System-dependent initialization.
     
    188182    int fd;
    189183{
     184    int taskid  = (int)rtems_pppd_taskid;
    190185    int pppdisc = PPPDISC;
    191186    int x;
     
    206201    if (ioctl(fd, TIOCSETD, &pppdisc) < 0)
    207202        fatal("ioctl(TIOCSETD): %m");
     203
     204    /* set pppd taskid into the driver */
     205    ioctl(fd, PPPIOCSTASK, &taskid);
    208206
    209207    if (!demand) {
     
    287285    int fd;
    288286{
     287    int taskid = (int)0;
     288
     289    /* clear pppd taskid from the driver */
     290    ioctl(fd, PPPIOCSTASK, &taskid);
     291
    289292    /* Reset non-blocking mode on fd. */
    290293    if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) < 0)
     
    345348{
    346349    struct termios     tios;
    347     struct ttywakeup   wakeup;
    348350
    349351    if (tcgetattr(fd, &tios) < 0)
     
    403405        fatal("tcsetattr: %m");
    404406    }
    405 
    406     /* set up callback function */
    407     wakeup.sw_pfn = sys_serialcallback;
    408     wakeup.sw_arg = (void *)fd;
    409     ioctl(fd, RTEMS_IO_RCVWAKEUP, &wakeup);
    410407
    411408    restore_term = 1;
     
    490487    if (debug);
    491488        dbglog("sent %P", p, len);
     489/*    printf("sent packet [%d]\n", len); */
    492490
    493491    if (write(ttyfd, p, len) < 0) {
     
    497495}
    498496
     497void
     498ppp_delay(void)
     499{
     500  rtems_interval     ticks;
     501
     502  /* recommended delay to help negotiation */
     503  ticks = 300000/rtems_bsdnet_microseconds_per_tick;
     504  rtems_task_wake_after(ticks);
     505}
    499506
    500507/*
     
    526533
    527534    if ((len = read(ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
    528         if (errno == EWOULDBLOCK || errno == EINTR)
    529             return -1;
     535        if (errno == EWOULDBLOCK || errno == EINTR) len = -1;
    530536        /*fatal("read: %m"); */
    531537    }
     538
     539/*    printf("read packet [%d]\n", len); */
    532540    return len;
    533541}
     
    948956    int cmd;
    949957{
     958    int    status;
    950959    struct sockaddr_in address;
    951960    struct sockaddr_in netmask;
  • c/src/libnetworking/pppd/upap.h

    rd8a78f4f r0286b9f  
    7777 * Timeouts.
    7878 */
    79 #define UPAP_DEFTIMEOUT 3       /* Timeout (seconds) for retransmitting req */
     79#define UPAP_DEFTIMEOUT 5       /* Timeout (seconds) for retransmitting req */
    8080#define UPAP_DEFREQTIME 30      /* Time to wait for auth-req from peer */
    8181
  • c/src/libnetworking/wrapup/Makefile.am

    rd8a78f4f r0286b9f  
    99endif
    1010
    11 NET_O_PIECES = kern lib libc net netinet nfs rtems rtems_servers rtems_telnetd pppd modem \
    12     $(POSIX_PIECES)
     11NET_O_PIECES = kern lib libc net netinet nfs rtems rtems_servers \
     12    rtems_telnetd pppd $(POSIX_PIECES)
    1313OBJS = $(foreach piece, $(NET_O_PIECES), ../$(piece)/$(ARCH)/*.o)
    1414LIB = $(ARCH)/libnetworking.a
  • cpukit/libnetworking/ChangeLog

    rd8a78f4f r0286b9f  
     12001-01-31      Mike Siers <mikes@poliac.com>
     2
     3        * Nice Update of PPPD support which eliminates the
     4        requiremetn that drivers be in the termios TASK_DRIVEN mode.
     5        Mike did significant testing and reports that it seems to be
     6        more stable and handle larger packets better.  This patch
     7        replaces the termios tasks with more general pppd network
     8        driver tasks.  The functions pppinput() and pppstart() get
     9        called from the interrupt service routine.
     10        * Makefile.am, configure.ac, net/Makefile.am, net/bpf.h,
     11        net/ethernet.h, net/if.c, net/if.h, net/if_arp.h, net/if_dl.h,
     12        net/if_ethersubr.c, net/if_llc.h, net/if_loop.c, net/if_ppp.h,
     13        net/if_pppvar.h, net/if_types.h, net/netisr.h, net/ppp-comp.h,
     14        net/ppp_defs.h, net/pppcompress.h, net/radix.c, net/radix.h,
     15        net/raw_cb.c, net/raw_cb.h, net/raw_usrreq.c, net/route.c,
     16        net/route.h, net/rtsock.c, pppd/Makefile.am, pppd/README,
     17        pppd/STATUS, pppd/auth.c, pppd/cbcp.c, pppd/ccp.c, pppd/ccp.h,
     18        pppd/chap.c, pppd/chap.h, pppd/chap_ms.c, pppd/chap_ms.h,
     19        pppd/chat.c, pppd/demand.c, pppd/fsm.c, pppd/fsm.h, pppd/ipcp.c,
     20        pppd/ipcp.h, pppd/ipxcp.c, pppd/ipxcp.h, pppd/lcp.c, pppd/lcp.h,
     21        pppd/magic.c, pppd/magic.h, pppd/options.c, pppd/patchlevel.h,
     22        pppd/pathnames.h, pppd/pppd.8, pppd/pppd.h, pppd/rtemsmain.c,
     23        pppd/rtemspppd.c, pppd/rtemspppd.h, pppd/sys-rtems.c, pppd/upap.c,
     24        pppd/upap.h, pppd/utils.c, pppd/example/README,
     25        pppd/example/netconfig.h, wrapup/Makefile.am: Modified.
     26        * net/bsd-comp.c, net/if_ppp.c, net/ppp-deflate.c, net/ppp.h,
     27        net/ppp_tty.c, net/pppcompress.c, net/zlib.c, net/zlib.h: New file.
     28        * modem/, modem/.cvsignore, modem/Makefile.am, modem/ppp.c,
     29        modem/ppp.h, modem/ppp_tty.c, modem/pppcompress.c: Subdirectory removed.
     30
    1312002-01-21      Ralf Corsepius <corsepiu@faw.uni-ulm.de>
    232
  • cpukit/libnetworking/Makefile.am

    rd8a78f4f r0286b9f  
    77
    88SUBDIRS = arpa kern machine sys vm lib libc net netinet nfs rtems \
    9     rtems_servers pppd modem rtems_telnetd rtems_webserver wrapup
     9    rtems_servers pppd rtems_telnetd rtems_webserver wrapup
    1010
    1111include_HEADERS = \
  • cpukit/libnetworking/configure.ac

    rd8a78f4f r0286b9f  
    4747nfs/Makefile
    4848pppd/Makefile
    49 modem/Makefile
    5049rtems/Makefile
    5150rtems_servers/Makefile
  • cpukit/libnetworking/net/Makefile.am

    rd8a78f4f r0286b9f  
    1111
    1212C_FILES = if.c if_ethersubr.c if_loop.c radix.c route.c rtsock.c raw_cb.c \
    13     raw_usrreq.c
     13    raw_usrreq.c if_ppp.c ppp_tty.c pppcompress.c
    1414C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)
    1515
  • cpukit/libnetworking/net/if_ppp.h

    rd8a78f4f r0286b9f  
    3939#define SC_LOG_RAWIN    0x00080000      /* log all chars received */
    4040#define SC_LOG_FLUSH    0x00100000      /* log all chars flushed */
    41 #define SC_SYNC         0x00200000      /* synchrounous HDLC */
    4241#define SC_RCV_B7_0     0x01000000      /* have rcvd char with bit 7 = 0 */
    4342#define SC_RCV_B7_1     0x02000000      /* have rcvd char with bit 7 = 1 */
    4443#define SC_RCV_EVNP     0x04000000      /* have rcvd char with even parity */
    4544#define SC_RCV_ODDP     0x08000000      /* have rcvd char with odd parity */
     45#define SC_SYNC         0x00200000      /* use synchronous HDLC framing */
    4646#define SC_MASK         0x0fff00ff      /* bits that user can change */
    4747
     
    9090 */
    9191
     92#define PPPIOCSTASK     _IOW('t', 91, int)      /* set pppd task id */
    9293#define PPPIOCGFLAGS    _IOR('t', 90, int)      /* get configuration flags */
    9394#define PPPIOCSFLAGS    _IOW('t', 89, int)      /* set configuration flags */
  • cpukit/libnetworking/net/if_pppvar.h

    rd8a78f4f r0286b9f  
    4646 * indexing sc_npmode.
    4747 */
    48 #define NP_IP   0               /* Internet Protocol */
    49 #define NUM_NP  1               /* Number of NPs. */
     48#define NP_IP                 0 /* Internet Protocol */
     49#define NUM_NP                1 /* Number of NPs. */
     50#define NUM_MBUFQ            64
     51
    5052
    5153/*
     
    6466        struct  ifqueue sc_inq;         /* queue of input packets for daemon */
    6567        struct  ifqueue sc_fastq;       /* interactive output packet q */
    66         struct  mbuf *sc_togo;          /* output packet ready to go */
    6768        struct  mbuf *sc_npqueue;       /* output packets not to be sent yet */
    6869        struct  mbuf **sc_npqtail;      /* ptr to last next ptr in npqueue */
     
    8586
    8687        /* Device-dependent part for async lines. */
    87         ext_accm sc_asyncmap;           /* async control character map */
    88         u_long  sc_rasyncmap;           /* receive async control char map */
    89         struct  mbuf *sc_outm;          /* mbuf chain currently being output */
    90         struct  mbuf *sc_m;             /* pointer to input mbuf chain */
    91         struct  mbuf *sc_mc;            /* pointer to current input mbuf */
    92         char    *sc_mp;                 /* ptr to next char in input mbuf */
    93         short   sc_ilen;                /* length of input packet so far */
    94         u_short sc_fcs;                 /* FCS so far (input) */
    95         u_short sc_outfcs;              /* FCS so far for output packet */
    96         u_char  sc_rawin[16];           /* chars as received */
    97         int     sc_rawin_count;         /* # in sc_rawin */
    98         rtems_id sem_id;                /* ID of comm semaphore         */
     88        ext_accm sc_asyncmap;                /* async control character map */
     89        u_long  sc_rasyncmap;                /* receive async control char map */
     90        struct  mbuf *sc_outm;               /* mbuf chain currently being output */
     91        struct  mbuf *sc_outmc;              /* mbuf currently being output */
     92        struct  mbuf *sc_m;                  /* pointer to input mbuf chain */
     93        struct  mbuf *sc_mc;                 /* pointer to current input mbuf */
     94        char    *sc_mp;                      /* ptr to next char in input mbuf */
     95        short   sc_ilen;                     /* length of input packet so far */
     96        u_short sc_fcs;                      /* FCS so far (input) */
     97        u_char  sc_rawin[16];                /* chars as received */
     98        int     sc_rawin_count;              /* # in sc_rawin */
     99        u_short sc_outfcs;                   /* FCS so far for output packet */
     100
     101        struct  ifqueue sc_freeq;            /* free packets */
     102        short   sc_outoff;                   /* output packet byte offset */
     103        short   sc_outflag;                  /* output status flag */
     104        short   sc_outlen;                   /* length of output packet */
     105        short   sc_outfcslen;                /* length of output fcs data */
     106        u_char  sc_outfcsbuf[8];             /* output packet fcs buffer */
     107        u_char *sc_outbuf;                   /* pointer to output data */
     108
     109        rtems_id sc_rxtask;
     110        rtems_id sc_txtask;
     111        rtems_id sc_pppdtask;
    99112};
    100113
     
    107120int     pppioctl __P((struct ppp_softc *sc, int cmd, caddr_t data,
    108121                      int flag, struct proc *p));
    109 void    ppp_restart __P((struct ppp_softc *sc));
    110 void    ppppktin __P((struct ppp_softc *sc, struct mbuf *m, int lost));
    111122struct  mbuf *ppp_dequeue __P((struct ppp_softc *sc));
     123u_short pppfcs __P((u_short fcs, u_char *cp, int len));
     124void    pppallocmbuf __P((struct ppp_softc *sc, struct mbuf **mp));
     125
     126
     127/* define event values */
     128#define RX_PACKET    RTEMS_EVENT_1
     129#define RX_MBUF      RTEMS_EVENT_2
     130#define RX_EMPTY     RTEMS_EVENT_3
     131#define TX_PACKET    RTEMS_EVENT_1
     132#define TX_TRANSMIT  RTEMS_EVENT_2
     133#define PPPD_EVENT   RTEMS_EVENT_31
     134
     135/* define out flag values */
     136#define SC_TX_BUSY      0x0001
     137#define SC_TX_FCS       0x0002
     138#define SC_TX_ESCAPE    0x0004
     139#define SC_TX_PENDING   0x0010
  • cpukit/libnetworking/net/ppp-comp.h

    rd8a78f4f r0286b9f  
    3636 */
    3737#ifndef DO_BSD_COMPRESS
    38 #define DO_BSD_COMPRESS 1       /* by default, include BSD-Compress */
     38#define DO_BSD_COMPRESS 0       /* by default, include BSD-Compress */
    3939#endif
    4040#ifndef DO_DEFLATE
    41 #define DO_DEFLATE      1       /* by default, include Deflate */
     41#define DO_DEFLATE      0       /* by default, include Deflate */
    4242#endif
    4343#define DO_PREDICTOR_1  0
  • cpukit/libnetworking/net/ppp_defs.h

    rd8a78f4f r0286b9f  
    7878#define PPP_ATCP        0x8029  /* AppleTalk Control Protocol */
    7979#define PPP_IPXCP       0x802b  /* IPX Control Protocol */
     80#define PPP_IPV6CP      0x8057  /* IPv6 Control Protocol */
    8081#define PPP_CCP         0x80fd  /* Compression Control Protocol */
    8182#define PPP_LCP         0xc021  /* Link Control Protocol */
     
    9798
    9899#if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) \
    99  && !defined(__FreeBSD__) && (NS_TARGET < 40) && !defined(__rtems__)
     100 && !defined(__FreeBSD__) && (NS_TARGET < 40)
    100101#ifdef  UINT32_T
    101102typedef UINT32_T        u_int32_t;
    102103#else
    103 typedef unsigned int    u_int32_t;
    104 typedef unsigned short  u_int16_t;
     104/*typedef unsigned int  u_int32_t;*/
     105/*typedef unsigned short  u_int16_t;*/
    105106#endif
    106107#endif
  • cpukit/libnetworking/wrapup/Makefile.am

    rd8a78f4f r0286b9f  
    99endif
    1010
    11 NET_O_PIECES = kern lib libc net netinet nfs rtems rtems_servers rtems_telnetd pppd modem \
    12     $(POSIX_PIECES)
     11NET_O_PIECES = kern lib libc net netinet nfs rtems rtems_servers \
     12    rtems_telnetd pppd $(POSIX_PIECES)
    1313OBJS = $(foreach piece, $(NET_O_PIECES), ../$(piece)/$(ARCH)/*.o)
    1414LIB = $(ARCH)/libnetworking.a
  • cpukit/pppd/Makefile.am

    rd8a78f4f r0286b9f  
    1111LIB = $(ARCH)/$(LIBNAME)
    1212
    13 C_FILES = auth.c ccp.c chap.c chap_ms.c chat.c demand.c fsm.c ipcp.c lcp.c magic.c options.c upap.c md4.c md5.c utils.c sys-rtems.c rtemsmain.c rtemspppd.c
     13C_FILES = auth.c ccp.c chap.c chap_ms.c chat.c demand.c fsm.c ipcp.c lcp.c \
     14    magic.c options.c upap.c md4.c md5.c utils.c sys-rtems.c rtemsmain.c \
     15    rtemspppd.c
    1416C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o)
    1517
     
    3436chat.c demand.c fsm.c fsm.h ipcp.c ipcp.h ipxcp.c ipxcp.h \
    3537lcp.c lcp.h magic.c magic.h md4.c md4.h md5.c md5.h options.c \
    36 patchlevel.h pathnames.h pppd.h rtemsmain.c rtemspppd.c rtemspppd.h \
    37 sys-rtems.c upap.c upap.h utils.c
     38patchlevel.h pathnames.h pppd.h rtemsdialer.h rtemsmain.c rtemspppd.c \
     39rtemspppd.h sys-rtems.c upap.c upap.h utils.c
    3840
    39 include_HEADERS = rtemspppd.h
     41include_HEADERS = rtemspppd.h rtemsdialer.h
    4042
    4143
  • cpukit/pppd/README

    rd8a78f4f r0286b9f  
    2121the ABORT commands.  Removed some dead code and did a lot of
    2222testing on a new Coldfire BSP.  Version seems to be very stable.
     23
     24Update code to use RTEMS pppd network drivers.  Now the pppd
     25software is not dependent on using task driven mode.  This
     26change improved stablity and performance.  This was updated
     27by Mike Siers <mikes@poliac.com>.
    2328=================================================================
    2429
  • cpukit/pppd/STATUS

    rd8a78f4f r0286b9f  
    1717with this function call.
    1818
    19 The pppd application requires the BSP termios driver support task
    20 driven I/O.  Below is a list of known issues that need to be resolved:
    21 
    22   - pppd locks up when it receives large packet pings (> 1500 bytes)
    23   - pppd occasionaly locks up with mbuf allocation error
    24     (problem is rare and may be BSP related)
     19The pppd code had now been updated to use it's own RTEMS network
     20drivers.  This removes the requirement for the task driven termios
     21support.  This update has fixed the large packet ping problem.
     22Currently, I do not know of any problems with the port.
    2523
    2624If you find any other problems or fix some problems, please post your
  • cpukit/pppd/chap.h

    rd8a78f4f r0286b9f  
    111111 * Timeouts.
    112112 */
    113 #define CHAP_DEFTIMEOUT         3       /* Timeout time in seconds */
     113#define CHAP_DEFTIMEOUT         5       /* Timeout time in seconds */
    114114#define CHAP_DEFTRANSMITS       10      /* max # times to send challenge */
    115115
  • cpukit/pppd/chat.c

    rd8a78f4f r0286b9f  
    157157char *phone_num      = (char *) 0;
    158158char *phone_num2     = (char *) 0;
     159static int ttyfd;
    159160static int timeout   = DEFAULT_CHAT_TIMEOUT;
    160161
     
    193194char *clean __P((register char *s, int sending));
    194195char *expect_strtok __P((char *, char *));
    195 int chatmain __P((char *));
     196int chatmain __P((int, int, char *));
    196197
    197198
     
    225226}
    226227
    227 int chatmain(argv)
    228 char *argv;
     228int chatmain(int fd, int mode, char *pScript)
    229229{
    230230  char    *arg;
     
    232232  /* initialize exit code */
    233233  exit_code = 0;
     234  ttyfd     = fd;
    234235
    235236  if ( debug ) {
    236     dbglog("chat_main: %s\n", argv);
     237    dbglog("chat_main: %s\n", pScript);
    237238  }
    238239
    239240  /* get first expect string */
    240   arg = getnextcommand(&argv);
     241  arg = getnextcommand(&pScript);
    241242  while (( arg != NULL ) && ( exit_code == 0 )) {
    242243    /* process the expect string */
     
    244245    if ( exit_code == 0 ) {
    245246      /* get the next send string */
    246       arg = getnextcommand(&argv);
     247      arg = getnextcommand(&pScript);
    247248      if ( arg != NULL ) {
    248249        /* process the send string */
     
    250251
    251252        /* get the next expect string */
    252         arg = getnextcommand(&argv);
     253        arg = getnextcommand(&pScript);
    253254      }
    254255    }
    255256  }
    256 
    257   if ( exit_code ) {
    258    exit_code = -exit_code;
    259   }
     257  ttyfd = (int)-1;
    260258
    261259  return ( exit_code );
  • cpukit/pppd/example/netconfig.h

    rd8a78f4f r0286b9f  
    66
    77/* external function prototypes */
    8 extern int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config,
    9                                    int attaching);
     8extern int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching);
    109
    1110/* Default network interface */
     
    1413  rtems_ppp_driver_attach,   /* attach function */
    1514  NULL,                      /* No more interfaces */
    16   "192.168.2.123",           /* IP address */
    17   "255.255.255.0",           /* IP net mask */
     15  NULL,                      /* IP address */
     16  NULL,                      /* IP net mask */
    1817  NULL,                      /* Driver supplies hardware address */
    1918  0                          /* Use default driver parameters */
     
    2423  &netdriver_config,
    2524  NULL,
    26   0,                  /* Default network task priority */
    27   0,                  /* Default mbuf capacity */
    28   0,                  /* Default mbuf cluster capacity */
    29   "rtems",            /* Host name */
    30   "xxxyyy.com",       /* Domain name */
     25  30,                 /* Default network task priority */
     26  (256*1024),         /* Default mbuf capacity */
     27  (512*1024),         /* Default mbuf cluster capacity */
     28  0,                  /* Host name */
     29  0,                  /* Domain name */
    3130  0,                  /* Gateway */
    3231  0,                  /* Log host */
  • cpukit/pppd/fsm.c

    rd8a78f4f r0286b9f  
    6060    f->state = INITIAL;
    6161    f->flags = 0;
    62     f->id = 0;                          /* XXX Start with random id? */
     62    f->id = 100;                /* XXX Start with random id? */
    6363    f->timeouttime = DEFTIMEOUT;
    6464    f->maxconfreqtransmits = DEFMAXCONFREQS;
     
    414414            if (f->callbacks->up)
    415415                (*f->callbacks->up)(f); /* Inform upper layers */
    416         } else
     416        } else {
    417417            f->state = ACKSENT;
     418            ppp_delay();
     419        }
    418420        f->nakloops = 0;
    419421
  • cpukit/pppd/fsm.h

    rd8a78f4f r0286b9f  
    120120 * Timeouts.
    121121 */
    122 #define DEFTIMEOUT      3       /* Timeout time in seconds */
     122#define DEFTIMEOUT      5       /* Timeout time in seconds */
    123123#define DEFMAXTERMREQS  2       /* Maximum Terminate-Request transmissions */
    124124#define DEFMAXCONFREQS  10      /* Maximum Configure-Request transmissions */
  • cpukit/pppd/ipcp.c

    rd8a78f4f r0286b9f  
    15711571    u_int32_t peerdns1, peerdns2;
    15721572{
    1573     FILE *f;
    1574 
    1575     f = fopen(_PATH_RESOLV, "w");
    1576     if (f == NULL) {
    1577         error("Failed to create %s: %m", _PATH_RESOLV);
    1578         return;
    1579     }
    1580 
    1581     if (peerdns1)
    1582         fprintf(f, "nameserver %s\n", ip_ntoa(peerdns1));
    1583 
    1584     if (peerdns2)
    1585         fprintf(f, "nameserver %s\n", ip_ntoa(peerdns2));
    1586 
    1587     if (ferror(f))
    1588         error("Write failed to %s: %m", _PATH_RESOLV);
    1589 
    1590     fclose(f);
     1573  extern int              rtems_bsdnet_nameserver_count;
     1574  extern struct in_addr   rtems_bsdnet_nameserver[];
     1575
     1576  /* initialize values */
     1577  rtems_bsdnet_nameserver_count = (int)0;
     1578
     1579  /* check to see if primary was specified */
     1580  if ( peerdns1 ) {
     1581    rtems_bsdnet_nameserver[rtems_bsdnet_nameserver_count].s_addr = peerdns1;
     1582    rtems_bsdnet_nameserver_count++;
     1583  }
     1584
     1585  /* check to see if secondary was specified */
     1586  if ( peerdns2 ) {
     1587    rtems_bsdnet_nameserver[rtems_bsdnet_nameserver_count].s_addr = peerdns2;
     1588    rtems_bsdnet_nameserver_count++;
     1589  }
     1590
     1591  /* initialize resolver */
     1592  __res_init();
    15911593}
    15921594
  • cpukit/pppd/options.c

    rd8a78f4f r0286b9f  
    716716            if (sv == NULL)
    717717                novm("option argument");
     718            if ( *(char **)(opt->addr) != NULL ) {
     719                free((void *)*(char **)(opt->addr));
     720                *(char **)(opt->addr) = NULL;
     721            }
    718722            *(char **)(opt->addr) = sv;
    719723        }
  • cpukit/pppd/pppd.h

    rd8a78f4f r0286b9f  
    2020 */
    2121
    22 /*
    23  * TODO:
    24  */
    25 
    2622#ifndef __PPPD_H__
    2723#define __PPPD_H__
     
    3329#include <sys/time.h>           /* for struct timeval */
    3430#include <net/ppp_defs.h>
     31#include "rtemsdialer.h"
    3532
    3633#if defined(__STDC__)
     
    168165extern int      do_callback;    /* set if we want to do callback next */
    169166extern int      doing_callback; /* set if this is a callback */
     167extern dialerfp pppd_dialer;    /* script dialer function callback */
    170168
    171169/* Values for do_callback and doing_callback */
     
    379377void setdtr __P((int, int));    /* Raise or lower port's DTR line */
    380378void output __P((int, u_char *, int)); /* Output a PPP packet */
    381 void wait_input __P((struct timeval *));
    382                                 /* Wait for input, with timeout */
     379void wait_input __P((struct timeval *)); /* Wait for input, with timeout */
     380
     381void ppp_delay __P((void));       /* delay task for a little while */
    383382int  read_packet __P((u_char *)); /* Read PPP packet */
    384383int  get_loop_output __P((void)); /* Read pkts from loopback */
  • cpukit/pppd/rtemsmain.c

    rd8a78f4f r0286b9f  
    4242#include <rtems.h>
    4343#include <rtems/rtems_bsdnet.h>
    44 extern void rtems_bsdnet_semaphore_obtain(void);
    45 extern void rtems_bsdnet_semaphore_release(void);
    46 extern int  chatmain(char *argv);
    4744
    4845#include "pppd.h"
     
    5956#include "pathnames.h"
    6057#include "patchlevel.h"
     58#include "rtemsdialer.h"
    6159
    6260#ifdef CBCP_SUPPORT
     
    9593int doing_callback;             /* != 0 if we are doing callback */
    9694char *callback_script;          /* script for doing callback */
     95dialerfp pppd_dialer;
    9796
    9897int (*holdoff_hook) __P((void)) = NULL;
     
    130129static struct timeval *timeleft __P((struct timeval *));
    131130static void holdoff_end __P((void *));
    132 static int device_script __P((char *, int, int, int));
     131static int device_script __P((int, int, char *));
    133132
    134133extern  char    *ttyname __P((int));
     
    313312
    314313            if (initializer && initializer[0]) {
    315                 if (device_script(initializer, ttyfd, ttyfd, 0) < 0) {
     314                if (device_script(ttyfd, DIALER_INIT, initializer) < 0) {
    316315                    error("Initializer script failed");
    317316                    status = EXIT_INIT_FAILED;
     
    325324
    326325            if (connector && connector[0]) {
    327                 if (device_script(connector, ttyfd, ttyfd, 0) < 0) {
     326                if (device_script(ttyfd, DIALER_CONNECT, connector) < 0) {
    328327                    error("Connect script failed");
    329328                    status = EXIT_CONNECT_FAILED;
     
    365364        /* run welcome script, if any */
    366365        if (welcomer && welcomer[0]) {
    367             if (device_script(welcomer, ttyfd, ttyfd, 0) < 0)
     366            if (device_script(ttyfd, DIALER_WELCOME, welcomer) < 0)
    368367                warn("Welcome script failed");
    369368        }
     
    388387        gettimeofday(&start_time, NULL);
    389388
    390         rtems_bsdnet_semaphore_obtain();
    391389        lcp_lowerup(0);
    392390        lcp_open(0);            /* Start protocol */
    393         rtems_bsdnet_semaphore_release();
    394391
    395392        open_ccp_flag = 0;
     
    399396            wait_input(timeleft(&timo));
    400397            calltimeout();
    401             get_input();
     398            get_input();
    402399
    403400            if (kill_link) {
     
    436433            if (real_ttyfd >= 0)
    437434                set_up_tty(real_ttyfd, 1);
    438             if (device_script(disconnect_script, ttyfd, ttyfd, 0) < 0) {
     435            if (device_script(ttyfd, DIALER_DISCONNECT, disconnect_script) < 0) {
    439436                warn("disconnect script failed");
    440437            } else {
     
    478475
    479476    die(status);
    480     return 0;
     477    return status;
    481478}
    482479
     
    579576 */
    580577static void
    581 get_input()
     578get_input(void)
    582579{
    583580    int len, i;
     
    609606    }
    610607
    611     rtems_bsdnet_semaphore_obtain();
    612608    p += 2;                             /* Skip address and control */
    613609    GETSHORT(protocol, p);
     
    619615    if (protocol != PPP_LCP && lcp_fsm[0].state != OPENED) {
    620616        MAINDEBUG(("get_input: Received non-LCP packet when LCP not open."));
    621         rtems_bsdnet_semaphore_release();
    622617        return;
    623618    }
     
    632627        MAINDEBUG(("get_input: discarding proto 0x%x in phase %d",
    633628                   protocol, phase));
    634         rtems_bsdnet_semaphore_release();
    635629        return;
    636630    }
     
    642636        if (protp->protocol == protocol && protp->enabled_flag) {
    643637            (*protp->input)(0, p, len);
    644             rtems_bsdnet_semaphore_release();
    645638            return;
    646639        }
     
    648641            && protp->datainput != NULL) {
    649642            (*protp->datainput)(0, p, len);
    650             rtems_bsdnet_semaphore_release();
    651643            return;
    652644        }
     
    661653    }
    662654    lcp_sprotrej(0, p - PPP_HDRLEN, len + PPP_HDRLEN);
    663     rtems_bsdnet_semaphore_release();
     655
     656    return;
    664657}
    665658
     
    873866 * (e.g. to run the connector or disconnector script).
    874867 */
    875 static int
    876 device_script(program, in, out, dont_wait)
    877     char *program;
    878     int in, out;
    879     int dont_wait;
    880 {
    881     char   pScript[256];
    882 
     868static int device_script(int fd, int mode, char *program)
     869{
     870    int    iReturn = -1;
     871    char   pScript[128];
     872
     873    /* copyt script into temporary location */
    883874    strcpy(pScript, program);
    884     return chatmain(pScript);
     875
     876    /* check to see if dialer was initialized */
     877    if ( !pppd_dialer ) {
     878      /* set default dialer to chatmain */
     879      pppd_dialer = chatmain;
     880    }
     881
     882    /* check to see if dialer is set */
     883    if ( pppd_dialer ) {
     884      /* call the dialer */
     885      iReturn = (*pppd_dialer)(fd, mode, program);
     886    }
     887
     888    return ( -iReturn );
    885889}
    886890
  • cpukit/pppd/rtemspppd.c

    rd8a78f4f r0286b9f  
    11
    22#include <rtems.h>
     3#include <rtems/rtems_bsdnet.h>
    34#include "pppd.h"
    45#include "rtemspppd.h"
     
    78/* define pppd function prototypes */
    89extern void pppasyncattach(void);
    9 extern int pppdmain(int, char **);
     10extern int  pppdmain(int, char **);
    1011
    1112/* define global variables */
    12 rtems_id rtems_pppd_taskid;
     13rtems_id                   rtems_pppd_taskid;
     14rtems_pppd_hookfunction    rtems_pppd_errorfp;
     15rtems_pppd_hookfunction    rtems_pppd_exitfp;
    1316
    1417
     
    1922  rtems_event_set     in;
    2023  rtems_event_set     out;
     24  int                 iStatus;
    2125
    2226  /* call function to setup ppp line discipline */
     
    3943        /* connect request */
    4044        /* execute the pppd main code */
    41         pppdmain(0, NULL);
     45        iStatus = pppdmain(0, NULL);
     46        if ( iStatus == EXIT_OK ) {
     47          /* check exit callback */
     48          if ( rtems_pppd_exitfp ) {
     49            (*rtems_pppd_exitfp)();
     50          }
     51        }
     52        else {
     53          /* check error callback */
     54          if ( rtems_pppd_errorfp ) {
     55            (*rtems_pppd_errorfp)();
     56          }
     57        }
    4258      }
    4359    }
     
    4561
    4662  /* terminate myself */
     63  rtems_pppd_taskid = 0;
    4764  rtems_task_delete(RTEMS_SELF);
    4865}
     
    5067int rtems_pppd_initialize(void)
    5168{
    52   int                 iReturn = (int)-1;
     69  int                 iReturn  = (int)-1;
     70  rtems_unsigned32    priority = 100;
    5371  rtems_status_code   status;
    5472  rtems_name          taskName;
    5573
     74  /* determine priority value */
     75  if ( rtems_bsdnet_config.network_task_priority ) {
     76    priority = rtems_bsdnet_config.network_task_priority;
     77  }
     78
     79  /* initialize the exit hook */
     80  rtems_pppd_exitfp = (rtems_pppd_hookfunction)0;
     81
     82  /* create the rtems task */
    5683  taskName = rtems_build_name( 'p', 'p', 'p', 'd' );
    57   status   = rtems_task_create(taskName,
    58                                RTEMS_PPPD_TASK_PRIORITY,
    59                                RTEMS_PPPD_TASK_STACK_SIZE,
    60                                RTEMS_PPPD_TASK_INITIAL_MODES,
    61                                RTEMS_DEFAULT_ATTRIBUTES,
     84  status   = rtems_task_create(taskName, priority, 8192,
     85                               (RTEMS_PREEMPT|RTEMS_NO_TIMESLICE|RTEMS_NO_ASR|RTEMS_INTERRUPT_LEVEL(0)),
     86                               RTEMS_NO_FLOATING_POINT|RTEMS_LOCAL,
    6287                               &rtems_pppd_taskid);
    6388  if ( status == RTEMS_SUCCESSFUL ) {
     
    115140    ip_down_hook = hookfp;
    116141    break;
     142  case RTEMS_PPPD_ERROR_HOOK:
     143    rtems_pppd_errorfp = hookfp;
     144    break;
     145  case RTEMS_PPPD_EXIT_HOOK:
     146    rtems_pppd_exitfp = hookfp;
     147    break;
    117148  default:
    118149    iReturn = (int)-1;
     
    121152
    122153  return ( iReturn );
     154}
     155
     156int rtems_pppd_set_dialer(rtems_pppd_dialerfunction dialerfp)
     157{
     158  pppd_dialer = dialerfp;
     159  return ( (int)0 );
    123160}
    124161
  • cpukit/pppd/rtemspppd.h

    rd8a78f4f r0286b9f  
    33#define RTEMSPPPD_H
    44
    5 /* check to see if pppd task values are set */
    6 #ifndef RTEMS_PPPD_TASK_PRIORITY
    7 #define RTEMS_PPPD_TASK_PRIORITY        120
    8 #endif
    9 #ifndef RTEMS_PPPD_TASK_STACK_SIZE
    10 #define RTEMS_PPPD_TASK_STACK_SIZE      (10*1024)
    11 #endif
    12 #ifndef RTEMS_PPPD_TASK_INITIAL_MODES
    13 #define RTEMS_PPPD_TASK_INITIAL_MODES   (RTEMS_PREEMPT | \
    14                                          RTEMS_NO_TIMESLICE | \
    15                                          RTEMS_NO_ASR | \
    16                                          RTEMS_INTERRUPT_LEVEL(0))
    17 #endif
    185
    196/* define hook function identifiers */
     
    229#define RTEMS_PPPD_IPUP_HOOK        3
    2310#define RTEMS_PPPD_IPDOWN_HOOK      4
     11#define RTEMS_PPPD_ERROR_HOOK       5
     12#define RTEMS_PPPD_EXIT_HOOK        6
    2413
    2514/* define hook function pointer prototype */
    2615typedef void (*rtems_pppd_hookfunction)(void);
     16typedef int  (*rtems_pppd_dialerfunction)(int tty, int mode, char *pScript);
    2717
    2818
     
    3222int rtems_pppd_reset_options(void);
    3323int rtems_pppd_set_hook(int id, rtems_pppd_hookfunction hookfp);
     24int rtems_pppd_set_dialer(rtems_pppd_dialerfunction dialerfp);
    3425int rtems_pppd_set_option(const char *pOption, const char *pValue);
    3526int rtems_pppd_connect(void);
  • cpukit/pppd/sys-rtems.c

    rd8a78f4f r0286b9f  
    9696
    9797
    98 void
    99 sys_serialcallback(struct termios *tty, void *arg)
    100 {
    101   rtems_event_send(rtems_pppd_taskid, RTEMS_EVENT_31);
    102 }
    103 
    10498/*
    10599 * sys_init - System-dependent initialization.
     
    188182    int fd;
    189183{
     184    int taskid  = (int)rtems_pppd_taskid;
    190185    int pppdisc = PPPDISC;
    191186    int x;
     
    206201    if (ioctl(fd, TIOCSETD, &pppdisc) < 0)
    207202        fatal("ioctl(TIOCSETD): %m");
     203
     204    /* set pppd taskid into the driver */
     205    ioctl(fd, PPPIOCSTASK, &taskid);
    208206
    209207    if (!demand) {
     
    287285    int fd;
    288286{
     287    int taskid = (int)0;
     288
     289    /* clear pppd taskid from the driver */
     290    ioctl(fd, PPPIOCSTASK, &taskid);
     291
    289292    /* Reset non-blocking mode on fd. */
    290293    if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) < 0)
     
    345348{
    346349    struct termios     tios;
    347     struct ttywakeup   wakeup;
    348350
    349351    if (tcgetattr(fd, &tios) < 0)
     
    403405        fatal("tcsetattr: %m");
    404406    }
    405 
    406     /* set up callback function */
    407     wakeup.sw_pfn = sys_serialcallback;
    408     wakeup.sw_arg = (void *)fd;
    409     ioctl(fd, RTEMS_IO_RCVWAKEUP, &wakeup);
    410407
    411408    restore_term = 1;
     
    490487    if (debug);
    491488        dbglog("sent %P", p, len);
     489/*    printf("sent packet [%d]\n", len); */
    492490
    493491    if (write(ttyfd, p, len) < 0) {
     
    497495}
    498496
     497void
     498ppp_delay(void)
     499{
     500  rtems_interval     ticks;
     501
     502  /* recommended delay to help negotiation */
     503  ticks = 300000/rtems_bsdnet_microseconds_per_tick;
     504  rtems_task_wake_after(ticks);
     505}
    499506
    500507/*
     
    526533
    527534    if ((len = read(ttyfd, buf, PPP_MTU + PPP_HDRLEN)) < 0) {
    528         if (errno == EWOULDBLOCK || errno == EINTR)
    529             return -1;
     535        if (errno == EWOULDBLOCK || errno == EINTR) len = -1;
    530536        /*fatal("read: %m"); */
    531537    }
     538
     539/*    printf("read packet [%d]\n", len); */
    532540    return len;
    533541}
     
    948956    int cmd;
    949957{
     958    int    status;
    950959    struct sockaddr_in address;
    951960    struct sockaddr_in netmask;
  • cpukit/pppd/upap.h

    rd8a78f4f r0286b9f  
    7777 * Timeouts.
    7878 */
    79 #define UPAP_DEFTIMEOUT 3       /* Timeout (seconds) for retransmitting req */
     79#define UPAP_DEFTIMEOUT 5       /* Timeout (seconds) for retransmitting req */
    8080#define UPAP_DEFREQTIME 30      /* Time to wait for auth-req from peer */
    8181
Note: See TracChangeset for help on using the changeset viewer.