Changeset 0286b9f in rtems
- Timestamp:
- 01/31/02 21:42:11 (22 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 5ec6f09
- Parents:
- d8a78f4f
- Files:
-
- 22 added
- 4 deleted
- 59 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
c/src/exec/libnetworking/ChangeLog
rd8a78f4f r0286b9f 1 2001-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 1 31 2002-01-21 Ralf Corsepius <corsepiu@faw.uni-ulm.de> 2 32 -
c/src/exec/libnetworking/Makefile.am
rd8a78f4f r0286b9f 7 7 8 8 SUBDIRS = arpa kern machine sys vm lib libc net netinet nfs rtems \ 9 rtems_servers pppd modemrtems_telnetd rtems_webserver wrapup9 rtems_servers pppd rtems_telnetd rtems_webserver wrapup 10 10 11 11 include_HEADERS = \ -
c/src/exec/libnetworking/configure.ac
rd8a78f4f r0286b9f 47 47 nfs/Makefile 48 48 pppd/Makefile 49 modem/Makefile50 49 rtems/Makefile 51 50 rtems_servers/Makefile -
c/src/exec/libnetworking/net/Makefile.am
rd8a78f4f r0286b9f 11 11 12 12 C_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 14 14 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) 15 15 -
c/src/exec/libnetworking/net/if_ppp.h
rd8a78f4f r0286b9f 39 39 #define SC_LOG_RAWIN 0x00080000 /* log all chars received */ 40 40 #define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */ 41 #define SC_SYNC 0x00200000 /* synchrounous HDLC */42 41 #define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */ 43 42 #define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 1 */ 44 43 #define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */ 45 44 #define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */ 45 #define SC_SYNC 0x00200000 /* use synchronous HDLC framing */ 46 46 #define SC_MASK 0x0fff00ff /* bits that user can change */ 47 47 … … 90 90 */ 91 91 92 #define PPPIOCSTASK _IOW('t', 91, int) /* set pppd task id */ 92 93 #define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */ 93 94 #define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */ -
c/src/exec/libnetworking/net/if_pppvar.h
rd8a78f4f r0286b9f 46 46 * indexing sc_npmode. 47 47 */ 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 50 52 51 53 /* … … 64 66 struct ifqueue sc_inq; /* queue of input packets for daemon */ 65 67 struct ifqueue sc_fastq; /* interactive output packet q */ 66 struct mbuf *sc_togo; /* output packet ready to go */67 68 struct mbuf *sc_npqueue; /* output packets not to be sent yet */ 68 69 struct mbuf **sc_npqtail; /* ptr to last next ptr in npqueue */ … … 85 86 86 87 /* 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; 99 112 }; 100 113 … … 107 120 int pppioctl __P((struct ppp_softc *sc, int cmd, caddr_t data, 108 121 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));111 122 struct mbuf *ppp_dequeue __P((struct ppp_softc *sc)); 123 u_short pppfcs __P((u_short fcs, u_char *cp, int len)); 124 void 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 36 36 */ 37 37 #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 */ 39 39 #endif 40 40 #ifndef DO_DEFLATE 41 #define DO_DEFLATE 1/* by default, include Deflate */41 #define DO_DEFLATE 0 /* by default, include Deflate */ 42 42 #endif 43 43 #define DO_PREDICTOR_1 0 -
c/src/exec/libnetworking/net/ppp_defs.h
rd8a78f4f r0286b9f 78 78 #define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ 79 79 #define PPP_IPXCP 0x802b /* IPX Control Protocol */ 80 #define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ 80 81 #define PPP_CCP 0x80fd /* Compression Control Protocol */ 81 82 #define PPP_LCP 0xc021 /* Link Control Protocol */ … … 97 98 98 99 #if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) \ 99 && !defined(__FreeBSD__) && (NS_TARGET < 40) && !defined(__rtems__)100 && !defined(__FreeBSD__) && (NS_TARGET < 40) 100 101 #ifdef UINT32_T 101 102 typedef UINT32_T u_int32_t; 102 103 #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;*/ 105 106 #endif 106 107 #endif -
c/src/exec/libnetworking/wrapup/Makefile.am
rd8a78f4f r0286b9f 9 9 endif 10 10 11 NET_O_PIECES = kern lib libc net netinet nfs rtems rtems_servers rtems_telnetd pppd modem\12 $(POSIX_PIECES)11 NET_O_PIECES = kern lib libc net netinet nfs rtems rtems_servers \ 12 rtems_telnetd pppd $(POSIX_PIECES) 13 13 OBJS = $(foreach piece, $(NET_O_PIECES), ../$(piece)/$(ARCH)/*.o) 14 14 LIB = $(ARCH)/libnetworking.a -
c/src/libnetworking/ChangeLog
rd8a78f4f r0286b9f 1 2001-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 1 31 2002-01-21 Ralf Corsepius <corsepiu@faw.uni-ulm.de> 2 32 -
c/src/libnetworking/Makefile.am
rd8a78f4f r0286b9f 7 7 8 8 SUBDIRS = arpa kern machine sys vm lib libc net netinet nfs rtems \ 9 rtems_servers pppd modemrtems_telnetd rtems_webserver wrapup9 rtems_servers pppd rtems_telnetd rtems_webserver wrapup 10 10 11 11 include_HEADERS = \ -
c/src/libnetworking/configure.ac
rd8a78f4f r0286b9f 47 47 nfs/Makefile 48 48 pppd/Makefile 49 modem/Makefile50 49 rtems/Makefile 51 50 rtems_servers/Makefile -
c/src/libnetworking/net/Makefile.am
rd8a78f4f r0286b9f 11 11 12 12 C_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 14 14 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) 15 15 -
c/src/libnetworking/net/if_ppp.c
rd8a78f4f r0286b9f 76 76 #include "ppp.h" 77 77 #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> 82 82 #include <sys/param.h> 83 83 #include <sys/systm.h> … … 90 90 #include <sys/malloc.h> 91 91 92 #include <rtems/rtems_bsdnet.h>93 92 #include <net/if.h> 94 #include <sys/errno.h>95 93 #include <net/if_types.h> 96 94 #include <net/netisr.h> … … 100 98 #endif 101 99 102 #if defINET100 #if INET 103 101 #include <netinet/in.h> 104 102 #include <netinet/in_systm.h> … … 107 105 #endif 108 106 109 #include <bpfilter.h>107 #include "bpfilter.h" 110 108 #if NBPFILTER > 0 111 109 #include <net/bpf.h> … … 123 121 #define splsoftnet splnet 124 122 125 #ifndef NETISR_PPP126 /* This definition should be moved to net/netisr.h */127 #define NETISR_PPP 26 /* PPP software interrupt */128 #endif129 130 123 #ifdef PPP_COMPRESS 131 124 #define PACKETPTR struct mbuf * 132 125 #include <net/ppp-comp.h> 133 126 #endif 134 extern struct ifqueue ipintrq; 127 135 128 static int pppsioctl __P((struct ifnet *, int, caddr_t)); 136 129 static void ppp_requeue __P((struct ppp_softc *)); … … 139 132 static void ppp_ccp_closed __P((struct ppp_softc *)); 140 133 #endif 141 static voidppp_inproc __P((struct ppp_softc *, struct mbuf *));134 static struct mbuf *ppp_inproc __P((struct ppp_softc *, struct mbuf *)); 142 135 static void pppdumpm __P((struct mbuf *m0)); 143 136 … … 172 165 extern struct compressor ppp_deflate, ppp_deflate_draft; 173 166 174 175 167 struct compressor *ppp_compressors[8] = { 176 168 #if DO_BSD_COMPRESS … … 184 176 }; 185 177 #endif /* PPP_COMPRESS */ 186 static struct timeval ppp_time; 187 188 TEXT_SET(pseudo_set, pppattach); 178 179 extern struct ifqueue ipintrq; 180 static struct timeval ppp_time; 181 182 TEXT_SET(pseudo_set, ppp_rxdaemon); 183 184 185 static 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 243 static 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 368 static 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 } 189 414 190 415 /* 191 416 * Called from boot code to establish ppp interfaces. 192 417 */ 193 int rtems_ppp_driver_attach (struct rtems_bsdnet_ifconfig *config, 194 int attaching) 418 int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching) 195 419 { 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; 200 422 201 423 for (sc = ppp_softc; i < NPPP; sc++) { … … 212 434 sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN; 213 435 sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN; 436 sc->sc_freeq.ifq_maxlen = NUM_MBUFQ; 437 438 /* initialize and attach */ 439 ppp_init(sc); 214 440 if_attach(&sc->sc_if); 215 441 #if NBPFILTER > 0 … … 217 443 #endif 218 444 } 219 /* hardcoded in rtems_glue.c 220 netisrs[NETISR_PPP] = pppintr; */ 221 return 1; 445 446 return ( 1 ); 222 447 } 223 448 … … 231 456 int nppp, i; 232 457 struct ppp_softc *sc; 458 233 459 for (nppp = 0, sc = ppp_softc; nppp < NPPP; nppp++, sc++) 234 460 if (sc->sc_xfer == pid) { … … 247 473 bzero((char *)&sc->sc_stats, sizeof(sc->sc_stats)); 248 474 #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); 250 477 if (sc->sc_comp) 251 478 vj_compress_init(sc->sc_comp, -1); … … 259 486 sc->sc_npqueue = NULL; 260 487 sc->sc_npqtail = &sc->sc_npqueue; 261 488 microtime(&ppp_time); 262 489 sc->sc_last_sent = sc->sc_last_recv = ppp_time.tv_sec; 263 490 … … 273 500 { 274 501 struct mbuf *m; 502 rtems_interrupt_level level; 275 503 276 504 if_down(&sc->sc_if); … … 278 506 sc->sc_devp = NULL; 279 507 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 286 534 for (;;) { 287 535 IF_DEQUEUE(&sc->sc_inq, m); … … 299 547 sc->sc_npqueue = m->m_nextpkt; 300 548 m_freem(m); 301 }302 if (sc->sc_togo != NULL) {303 m_freem(sc->sc_togo);304 sc->sc_togo = NULL;305 549 } 306 550 #ifdef PPP_COMPRESS … … 311 555 #ifdef PPP_FILTER 312 556 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); 314 558 sc->sc_pass_filt.bf_insns = 0; 315 559 sc->sc_pass_filt.bf_len = 0; 316 560 } 317 561 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); 319 563 sc->sc_active_filt.bf_insns = 0; 320 564 sc->sc_active_filt.bf_len = 0; … … 323 567 #ifdef VJC 324 568 if (sc->sc_comp != 0) { 325 free(sc->sc_comp, M_DEVBUF);569 FREE(sc->sc_comp, M_DEVBUF); 326 570 sc->sc_comp = 0; 327 571 } … … 340 584 struct proc *p; 341 585 { 342 int s, flags, mru, npx ;586 int s, flags, mru, npx, taskid; 343 587 struct npioctl *npi; 344 588 time_t t; … … 361 605 break; 362 606 607 case PPPIOCSTASK: 608 taskid = *(int *)data; 609 sc->sc_pppdtask = taskid; 610 break; 611 363 612 case PPPIOCGUNIT: 364 613 *(int *)data = sc->sc_if.if_unit; … … 383 632 case PPPIOCSMRU: 384 633 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 } 387 645 break; 388 646 … … 489 747 case PPPIOCGIDLE: 490 748 s = splsoftnet(); 491 749 microtime(&ppp_time); 492 750 t = ppp_time.tv_sec; 493 751 ((struct ppp_idle *)data)->xmit_idle = t - sc->sc_last_sent; … … 504 762 newcodelen = nbp->bf_len * sizeof(struct bpf_insn); 505 763 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); 507 765 if (newcode == 0) { 508 766 return EINVAL; /* or sumpin */ … … 510 768 if ((error = copyin((caddr_t)nbp->bf_insns, (caddr_t)newcode, 511 769 newcodelen)) != 0) { 512 free(newcode, M_DEVBUF);770 FREE(newcode, M_DEVBUF); 513 771 return error; 514 772 } 515 773 if (!bpf_validate(newcode, nbp->bf_len)) { 516 free(newcode, M_DEVBUF);774 FREE(newcode, M_DEVBUF); 517 775 return EINVAL; 518 776 } … … 526 784 splx(s); 527 785 if (oldcode != 0) 528 free(oldcode, M_DEVBUF);786 FREE(oldcode, M_DEVBUF); 529 787 break; 530 788 #endif … … 545 803 caddr_t data; 546 804 { 547 /* struct proc *p = curproc; *//* XXX */805 /*struct proc *p = curproc;*/ /* XXX */ 548 806 register struct ppp_softc *sc = &ppp_softc[ifp->if_unit]; 549 807 register struct ifaddr *ifa = (struct ifaddr *)data; … … 595 853 } 596 854 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; 608 865 609 866 case SIOCGPPPSTATS: … … 663 920 int len; 664 921 struct mbuf *m; 922 665 923 if (sc->sc_devp == NULL || (ifp->if_flags & IFF_RUNNING) == 0 666 924 || ((ifp->if_flags & IFF_UP) == 0 && dst->sa_family != AF_UNSPEC)) { … … 763 1021 if (sc->sc_active_filt.bf_insns == 0 764 1022 || 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; 769 1024 770 1025 *mtod(m0, u_char *) = address; … … 773 1028 * Update the time we sent the most recent data packet. 774 1029 */ 775 1030 microtime(&ppp_time); 776 1031 sc->sc_last_sent = ppp_time.tv_sec; 777 1032 #endif /* PPP_FILTER */ … … 789 1044 * Put the packet on the appropriate queue. 790 1045 */ 1046 s = splsoftnet(); 791 1047 if (mode == NPMODE_QUEUE) { 792 1048 /* XXX we should limit the number of packets on this queue */ … … 807 1063 (*sc->sc_start)(sc); 808 1064 } 809 microtime(&ppp_time);810 1065 ifp->if_lastchange = ppp_time; 811 1066 ifp->if_opackets++; 812 1067 ifp->if_obytes += len; 813 1068 1069 splx(s); 814 1070 return (0); 815 1071 … … 872 1128 873 1129 /* 874 * Transmitter has finished outputting some stuff;875 * remember to call sc->sc_start later at splsoftnet.876 */877 void878 ppp_restart(sc)879 struct ppp_softc *sc;880 {881 882 sc->sc_flags &= ~SC_TBUSY;883 /* schednetisr(NETISR_PPP);884 */}885 886 /*887 1130 * Get a packet to send. This procedure is intended to be called at 888 1131 * splsoftnet, since it may involve time-consuming operations such as … … 902 1145 * normal queue. 903 1146 */ 1147 rtems_bsdnet_semaphore_obtain(); 904 1148 IF_DEQUEUE(&sc->sc_fastq, m); 905 1149 if (m == NULL) 906 1150 IF_DEQUEUE(&sc->sc_if.if_snd, m); 1151 rtems_bsdnet_semaphore_release(); 1152 907 1153 if (m == NULL) 908 1154 return NULL; … … 1019 1265 */ 1020 1266 void 1021 pppintr( )1267 pppintr(void) 1022 1268 { 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 }1043 1269 } 1044 1270 … … 1161 1387 1162 1388 /* 1163 * PPP packet input routine.1164 * The caller has checked and removed the FCS and has inserted1165 * the address/control bytes and the protocol high byte if they1166 * were omitted.1167 */1168 void1169 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 /*1182 1389 * Process a received PPP packet, doing decompression as necessary. 1183 1390 * Should be called at splsoftnet. … … 1186 1393 TYPE_UNCOMPRESSED_TCP) 1187 1394 1188 static void1395 static struct mbuf * 1189 1396 ppp_inproc(sc, m) 1190 1397 struct ppp_softc *sc; 1191 1398 struct mbuf *m; 1192 1399 { 1400 struct mbuf *mf = (struct mbuf *)0; 1193 1401 struct ifnet *ifp = &sc->sc_if; 1194 1402 struct ifqueue *inq; 1195 int s, ilen, xlen, proto, rv; 1403 int s, ilen, xlen, proto, rv; 1196 1404 u_char *cp, adrs, ctrl; 1197 1405 struct mbuf *mp; 1198 1406 #ifdef PPP_COMPRESS 1199 *dmp = NULL;1407 struct mbuf *dmp = NULL; 1200 1408 #endif 1201 1409 u_char *iphdr; … … 1237 1445 if (dmp == NULL) { 1238 1446 /* no error, but no decompressed packet produced */ 1239 return ;1447 return mf; 1240 1448 } 1241 1449 m = dmp; … … 1370 1578 if (mp != NULL) { 1371 1579 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; 1373 1583 m = mp; 1374 1584 m->m_len = ilen; … … 1391 1601 /* drop this packet */ 1392 1602 m_freem(m); 1393 return ;1603 return mf; 1394 1604 } 1395 1605 if (sc->sc_active_filt.bf_insns == 0 1396 1606 || 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; 1402 1608 1403 1609 *mtod(m, u_char *) = adrs; … … 1428 1634 /* interface is down - drop the packet. */ 1429 1635 m_freem(m); 1430 return ;1636 return mf; 1431 1637 } 1432 1638 m->m_pkthdr.len -= PPP_HDRLEN; … … 1461 1667 IF_ENQUEUE(inq, m); 1462 1668 splx(s); 1669 1463 1670 ifp->if_ipackets++; 1464 1671 ifp->if_ibytes += ilen; 1465 1672 microtime(&ppp_time); 1466 1673 ifp->if_lastchange = ppp_time; 1467 1674 1468 if (rv) 1469 (*sc->sc_ctlp)(sc); 1470 1471 return; 1675 if (rv) { 1676 (*sc->sc_ctlp)(sc); 1677 } 1678 1679 return mf; 1472 1680 1473 1681 bad: … … 1475 1683 sc->sc_if.if_ierrors++; 1476 1684 sc->sc_stats.ppp_ierrors++; 1685 return mf; 1477 1686 } 1478 1687 -
c/src/libnetworking/net/if_ppp.h
rd8a78f4f r0286b9f 39 39 #define SC_LOG_RAWIN 0x00080000 /* log all chars received */ 40 40 #define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */ 41 #define SC_SYNC 0x00200000 /* synchrounous HDLC */42 41 #define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */ 43 42 #define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 1 */ 44 43 #define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */ 45 44 #define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */ 45 #define SC_SYNC 0x00200000 /* use synchronous HDLC framing */ 46 46 #define SC_MASK 0x0fff00ff /* bits that user can change */ 47 47 … … 90 90 */ 91 91 92 #define PPPIOCSTASK _IOW('t', 91, int) /* set pppd task id */ 92 93 #define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */ 93 94 #define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */ -
c/src/libnetworking/net/if_pppvar.h
rd8a78f4f r0286b9f 46 46 * indexing sc_npmode. 47 47 */ 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 50 52 51 53 /* … … 64 66 struct ifqueue sc_inq; /* queue of input packets for daemon */ 65 67 struct ifqueue sc_fastq; /* interactive output packet q */ 66 struct mbuf *sc_togo; /* output packet ready to go */67 68 struct mbuf *sc_npqueue; /* output packets not to be sent yet */ 68 69 struct mbuf **sc_npqtail; /* ptr to last next ptr in npqueue */ … … 85 86 86 87 /* 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; 99 112 }; 100 113 … … 107 120 int pppioctl __P((struct ppp_softc *sc, int cmd, caddr_t data, 108 121 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));111 122 struct mbuf *ppp_dequeue __P((struct ppp_softc *sc)); 123 u_short pppfcs __P((u_short fcs, u_char *cp, int len)); 124 void 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 36 36 */ 37 37 #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 */ 39 39 #endif 40 40 #ifndef DO_DEFLATE 41 #define DO_DEFLATE 1/* by default, include Deflate */41 #define DO_DEFLATE 0 /* by default, include Deflate */ 42 42 #endif 43 43 #define DO_PREDICTOR_1 0 -
c/src/libnetworking/net/ppp_defs.h
rd8a78f4f r0286b9f 78 78 #define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ 79 79 #define PPP_IPXCP 0x802b /* IPX Control Protocol */ 80 #define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ 80 81 #define PPP_CCP 0x80fd /* Compression Control Protocol */ 81 82 #define PPP_LCP 0xc021 /* Link Control Protocol */ … … 97 98 98 99 #if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) \ 99 && !defined(__FreeBSD__) && (NS_TARGET < 40) && !defined(__rtems__)100 && !defined(__FreeBSD__) && (NS_TARGET < 40) 100 101 #ifdef UINT32_T 101 102 typedef UINT32_T u_int32_t; 102 103 #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;*/ 105 106 #endif 106 107 #endif -
c/src/libnetworking/pppd/Makefile.am
rd8a78f4f r0286b9f 11 11 LIB = $(ARCH)/$(LIBNAME) 12 12 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 13 C_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 14 16 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) 15 17 … … 34 36 chat.c demand.c fsm.c fsm.h ipcp.c ipcp.h ipxcp.c ipxcp.h \ 35 37 lcp.c lcp.h magic.c magic.h md4.c md4.h md5.c md5.h options.c \ 36 patchlevel.h pathnames.h pppd.h rtems main.c rtemspppd.c rtemspppd.h\37 sys-rtems.c upap.c upap.h utils.c38 patchlevel.h pathnames.h pppd.h rtemsdialer.h rtemsmain.c rtemspppd.c \ 39 rtemspppd.h sys-rtems.c upap.c upap.h utils.c 38 40 39 include_HEADERS = rtemspppd.h 41 include_HEADERS = rtemspppd.h rtemsdialer.h 40 42 41 43 -
c/src/libnetworking/pppd/README
rd8a78f4f r0286b9f 21 21 the ABORT commands. Removed some dead code and did a lot of 22 22 testing on a new Coldfire BSP. Version seems to be very stable. 23 24 Update code to use RTEMS pppd network drivers. Now the pppd 25 software is not dependent on using task driven mode. This 26 change improved stablity and performance. This was updated 27 by Mike Siers <mikes@poliac.com>. 23 28 ================================================================= 24 29 -
c/src/libnetworking/pppd/STATUS
rd8a78f4f r0286b9f 17 17 with this function call. 18 18 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) 19 The pppd code had now been updated to use it's own RTEMS network 20 drivers. This removes the requirement for the task driven termios 21 support. This update has fixed the large packet ping problem. 22 Currently, I do not know of any problems with the port. 25 23 26 24 If you find any other problems or fix some problems, please post your -
c/src/libnetworking/pppd/chap.h
rd8a78f4f r0286b9f 111 111 * Timeouts. 112 112 */ 113 #define CHAP_DEFTIMEOUT 3/* Timeout time in seconds */113 #define CHAP_DEFTIMEOUT 5 /* Timeout time in seconds */ 114 114 #define CHAP_DEFTRANSMITS 10 /* max # times to send challenge */ 115 115 -
c/src/libnetworking/pppd/chat.c
rd8a78f4f r0286b9f 157 157 char *phone_num = (char *) 0; 158 158 char *phone_num2 = (char *) 0; 159 static int ttyfd; 159 160 static int timeout = DEFAULT_CHAT_TIMEOUT; 160 161 … … 193 194 char *clean __P((register char *s, int sending)); 194 195 char *expect_strtok __P((char *, char *)); 195 int chatmain __P(( char *));196 int chatmain __P((int, int, char *)); 196 197 197 198 … … 225 226 } 226 227 227 int chatmain(argv) 228 char *argv; 228 int chatmain(int fd, int mode, char *pScript) 229 229 { 230 230 char *arg; … … 232 232 /* initialize exit code */ 233 233 exit_code = 0; 234 ttyfd = fd; 234 235 235 236 if ( debug ) { 236 dbglog("chat_main: %s\n", argv);237 dbglog("chat_main: %s\n", pScript); 237 238 } 238 239 239 240 /* get first expect string */ 240 arg = getnextcommand(& argv);241 arg = getnextcommand(&pScript); 241 242 while (( arg != NULL ) && ( exit_code == 0 )) { 242 243 /* process the expect string */ … … 244 245 if ( exit_code == 0 ) { 245 246 /* get the next send string */ 246 arg = getnextcommand(& argv);247 arg = getnextcommand(&pScript); 247 248 if ( arg != NULL ) { 248 249 /* process the send string */ … … 250 251 251 252 /* get the next expect string */ 252 arg = getnextcommand(& argv);253 arg = getnextcommand(&pScript); 253 254 } 254 255 } 255 256 } 256 257 if ( exit_code ) { 258 exit_code = -exit_code; 259 } 257 ttyfd = (int)-1; 260 258 261 259 return ( exit_code ); -
c/src/libnetworking/pppd/example/netconfig.h
rd8a78f4f r0286b9f 6 6 7 7 /* external function prototypes */ 8 extern int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, 9 int attaching); 8 extern int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching); 10 9 11 10 /* Default network interface */ … … 14 13 rtems_ppp_driver_attach, /* attach function */ 15 14 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 */ 18 17 NULL, /* Driver supplies hardware address */ 19 18 0 /* Use default driver parameters */ … … 24 23 &netdriver_config, 25 24 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 */ 31 30 0, /* Gateway */ 32 31 0, /* Log host */ -
c/src/libnetworking/pppd/fsm.c
rd8a78f4f r0286b9f 60 60 f->state = INITIAL; 61 61 f->flags = 0; 62 f->id = 0;/* XXX Start with random id? */62 f->id = 100; /* XXX Start with random id? */ 63 63 f->timeouttime = DEFTIMEOUT; 64 64 f->maxconfreqtransmits = DEFMAXCONFREQS; … … 414 414 if (f->callbacks->up) 415 415 (*f->callbacks->up)(f); /* Inform upper layers */ 416 } else 416 } else { 417 417 f->state = ACKSENT; 418 ppp_delay(); 419 } 418 420 f->nakloops = 0; 419 421 -
c/src/libnetworking/pppd/fsm.h
rd8a78f4f r0286b9f 120 120 * Timeouts. 121 121 */ 122 #define DEFTIMEOUT 3/* Timeout time in seconds */122 #define DEFTIMEOUT 5 /* Timeout time in seconds */ 123 123 #define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */ 124 124 #define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */ -
c/src/libnetworking/pppd/ipcp.c
rd8a78f4f r0286b9f 1571 1571 u_int32_t peerdns1, peerdns2; 1572 1572 { 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(); 1591 1593 } 1592 1594 -
c/src/libnetworking/pppd/options.c
rd8a78f4f r0286b9f 716 716 if (sv == NULL) 717 717 novm("option argument"); 718 if ( *(char **)(opt->addr) != NULL ) { 719 free((void *)*(char **)(opt->addr)); 720 *(char **)(opt->addr) = NULL; 721 } 718 722 *(char **)(opt->addr) = sv; 719 723 } -
c/src/libnetworking/pppd/pppd.h
rd8a78f4f r0286b9f 20 20 */ 21 21 22 /*23 * TODO:24 */25 26 22 #ifndef __PPPD_H__ 27 23 #define __PPPD_H__ … … 33 29 #include <sys/time.h> /* for struct timeval */ 34 30 #include <net/ppp_defs.h> 31 #include "rtemsdialer.h" 35 32 36 33 #if defined(__STDC__) … … 168 165 extern int do_callback; /* set if we want to do callback next */ 169 166 extern int doing_callback; /* set if this is a callback */ 167 extern dialerfp pppd_dialer; /* script dialer function callback */ 170 168 171 169 /* Values for do_callback and doing_callback */ … … 379 377 void setdtr __P((int, int)); /* Raise or lower port's DTR line */ 380 378 void output __P((int, u_char *, int)); /* Output a PPP packet */ 381 void wait_input __P((struct timeval *)); 382 /* Wait for input, with timeout */ 379 void wait_input __P((struct timeval *)); /* Wait for input, with timeout */ 380 381 void ppp_delay __P((void)); /* delay task for a little while */ 383 382 int read_packet __P((u_char *)); /* Read PPP packet */ 384 383 int get_loop_output __P((void)); /* Read pkts from loopback */ -
c/src/libnetworking/pppd/rtemsmain.c
rd8a78f4f r0286b9f 42 42 #include <rtems.h> 43 43 #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);47 44 48 45 #include "pppd.h" … … 59 56 #include "pathnames.h" 60 57 #include "patchlevel.h" 58 #include "rtemsdialer.h" 61 59 62 60 #ifdef CBCP_SUPPORT … … 95 93 int doing_callback; /* != 0 if we are doing callback */ 96 94 char *callback_script; /* script for doing callback */ 95 dialerfp pppd_dialer; 97 96 98 97 int (*holdoff_hook) __P((void)) = NULL; … … 130 129 static struct timeval *timeleft __P((struct timeval *)); 131 130 static void holdoff_end __P((void *)); 132 static int device_script __P(( char *, int, int, int));131 static int device_script __P((int, int, char *)); 133 132 134 133 extern char *ttyname __P((int)); … … 313 312 314 313 if (initializer && initializer[0]) { 315 if (device_script( initializer, ttyfd, ttyfd, 0) < 0) {314 if (device_script(ttyfd, DIALER_INIT, initializer) < 0) { 316 315 error("Initializer script failed"); 317 316 status = EXIT_INIT_FAILED; … … 325 324 326 325 if (connector && connector[0]) { 327 if (device_script( connector, ttyfd, ttyfd, 0) < 0) {326 if (device_script(ttyfd, DIALER_CONNECT, connector) < 0) { 328 327 error("Connect script failed"); 329 328 status = EXIT_CONNECT_FAILED; … … 365 364 /* run welcome script, if any */ 366 365 if (welcomer && welcomer[0]) { 367 if (device_script( welcomer, ttyfd, ttyfd, 0) < 0)366 if (device_script(ttyfd, DIALER_WELCOME, welcomer) < 0) 368 367 warn("Welcome script failed"); 369 368 } … … 388 387 gettimeofday(&start_time, NULL); 389 388 390 rtems_bsdnet_semaphore_obtain();391 389 lcp_lowerup(0); 392 390 lcp_open(0); /* Start protocol */ 393 rtems_bsdnet_semaphore_release();394 391 395 392 open_ccp_flag = 0; … … 399 396 wait_input(timeleft(&timo)); 400 397 calltimeout(); 401 398 get_input(); 402 399 403 400 if (kill_link) { … … 436 433 if (real_ttyfd >= 0) 437 434 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) { 439 436 warn("disconnect script failed"); 440 437 } else { … … 478 475 479 476 die(status); 480 return 0;477 return status; 481 478 } 482 479 … … 579 576 */ 580 577 static void 581 get_input( )578 get_input(void) 582 579 { 583 580 int len, i; … … 609 606 } 610 607 611 rtems_bsdnet_semaphore_obtain();612 608 p += 2; /* Skip address and control */ 613 609 GETSHORT(protocol, p); … … 619 615 if (protocol != PPP_LCP && lcp_fsm[0].state != OPENED) { 620 616 MAINDEBUG(("get_input: Received non-LCP packet when LCP not open.")); 621 rtems_bsdnet_semaphore_release();622 617 return; 623 618 } … … 632 627 MAINDEBUG(("get_input: discarding proto 0x%x in phase %d", 633 628 protocol, phase)); 634 rtems_bsdnet_semaphore_release();635 629 return; 636 630 } … … 642 636 if (protp->protocol == protocol && protp->enabled_flag) { 643 637 (*protp->input)(0, p, len); 644 rtems_bsdnet_semaphore_release();645 638 return; 646 639 } … … 648 641 && protp->datainput != NULL) { 649 642 (*protp->datainput)(0, p, len); 650 rtems_bsdnet_semaphore_release();651 643 return; 652 644 } … … 661 653 } 662 654 lcp_sprotrej(0, p - PPP_HDRLEN, len + PPP_HDRLEN); 663 rtems_bsdnet_semaphore_release(); 655 656 return; 664 657 } 665 658 … … 873 866 * (e.g. to run the connector or disconnector script). 874 867 */ 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 868 static 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 */ 883 874 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 ); 885 889 } 886 890 -
c/src/libnetworking/pppd/rtemspppd.c
rd8a78f4f r0286b9f 1 1 2 2 #include <rtems.h> 3 #include <rtems/rtems_bsdnet.h> 3 4 #include "pppd.h" 4 5 #include "rtemspppd.h" … … 7 8 /* define pppd function prototypes */ 8 9 extern void pppasyncattach(void); 9 extern int pppdmain(int, char **);10 extern int pppdmain(int, char **); 10 11 11 12 /* define global variables */ 12 rtems_id rtems_pppd_taskid; 13 rtems_id rtems_pppd_taskid; 14 rtems_pppd_hookfunction rtems_pppd_errorfp; 15 rtems_pppd_hookfunction rtems_pppd_exitfp; 13 16 14 17 … … 19 22 rtems_event_set in; 20 23 rtems_event_set out; 24 int iStatus; 21 25 22 26 /* call function to setup ppp line discipline */ … … 39 43 /* connect request */ 40 44 /* 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 } 42 58 } 43 59 } … … 45 61 46 62 /* terminate myself */ 63 rtems_pppd_taskid = 0; 47 64 rtems_task_delete(RTEMS_SELF); 48 65 } … … 50 67 int rtems_pppd_initialize(void) 51 68 { 52 int iReturn = (int)-1; 69 int iReturn = (int)-1; 70 rtems_unsigned32 priority = 100; 53 71 rtems_status_code status; 54 72 rtems_name taskName; 55 73 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 */ 56 83 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, 62 87 &rtems_pppd_taskid); 63 88 if ( status == RTEMS_SUCCESSFUL ) { … … 115 140 ip_down_hook = hookfp; 116 141 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; 117 148 default: 118 149 iReturn = (int)-1; … … 121 152 122 153 return ( iReturn ); 154 } 155 156 int rtems_pppd_set_dialer(rtems_pppd_dialerfunction dialerfp) 157 { 158 pppd_dialer = dialerfp; 159 return ( (int)0 ); 123 160 } 124 161 -
c/src/libnetworking/pppd/rtemspppd.h
rd8a78f4f r0286b9f 3 3 #define RTEMSPPPD_H 4 4 5 /* check to see if pppd task values are set */6 #ifndef RTEMS_PPPD_TASK_PRIORITY7 #define RTEMS_PPPD_TASK_PRIORITY 1208 #endif9 #ifndef RTEMS_PPPD_TASK_STACK_SIZE10 #define RTEMS_PPPD_TASK_STACK_SIZE (10*1024)11 #endif12 #ifndef RTEMS_PPPD_TASK_INITIAL_MODES13 #define RTEMS_PPPD_TASK_INITIAL_MODES (RTEMS_PREEMPT | \14 RTEMS_NO_TIMESLICE | \15 RTEMS_NO_ASR | \16 RTEMS_INTERRUPT_LEVEL(0))17 #endif18 5 19 6 /* define hook function identifiers */ … … 22 9 #define RTEMS_PPPD_IPUP_HOOK 3 23 10 #define RTEMS_PPPD_IPDOWN_HOOK 4 11 #define RTEMS_PPPD_ERROR_HOOK 5 12 #define RTEMS_PPPD_EXIT_HOOK 6 24 13 25 14 /* define hook function pointer prototype */ 26 15 typedef void (*rtems_pppd_hookfunction)(void); 16 typedef int (*rtems_pppd_dialerfunction)(int tty, int mode, char *pScript); 27 17 28 18 … … 32 22 int rtems_pppd_reset_options(void); 33 23 int rtems_pppd_set_hook(int id, rtems_pppd_hookfunction hookfp); 24 int rtems_pppd_set_dialer(rtems_pppd_dialerfunction dialerfp); 34 25 int rtems_pppd_set_option(const char *pOption, const char *pValue); 35 26 int rtems_pppd_connect(void); -
c/src/libnetworking/pppd/sys-rtems.c
rd8a78f4f r0286b9f 96 96 97 97 98 void99 sys_serialcallback(struct termios *tty, void *arg)100 {101 rtems_event_send(rtems_pppd_taskid, RTEMS_EVENT_31);102 }103 104 98 /* 105 99 * sys_init - System-dependent initialization. … … 188 182 int fd; 189 183 { 184 int taskid = (int)rtems_pppd_taskid; 190 185 int pppdisc = PPPDISC; 191 186 int x; … … 206 201 if (ioctl(fd, TIOCSETD, &pppdisc) < 0) 207 202 fatal("ioctl(TIOCSETD): %m"); 203 204 /* set pppd taskid into the driver */ 205 ioctl(fd, PPPIOCSTASK, &taskid); 208 206 209 207 if (!demand) { … … 287 285 int fd; 288 286 { 287 int taskid = (int)0; 288 289 /* clear pppd taskid from the driver */ 290 ioctl(fd, PPPIOCSTASK, &taskid); 291 289 292 /* Reset non-blocking mode on fd. */ 290 293 if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) < 0) … … 345 348 { 346 349 struct termios tios; 347 struct ttywakeup wakeup;348 350 349 351 if (tcgetattr(fd, &tios) < 0) … … 403 405 fatal("tcsetattr: %m"); 404 406 } 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);410 407 411 408 restore_term = 1; … … 490 487 if (debug); 491 488 dbglog("sent %P", p, len); 489 /* printf("sent packet [%d]\n", len); */ 492 490 493 491 if (write(ttyfd, p, len) < 0) { … … 497 495 } 498 496 497 void 498 ppp_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 } 499 506 500 507 /* … … 526 533 527 534 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; 530 536 /*fatal("read: %m"); */ 531 537 } 538 539 /* printf("read packet [%d]\n", len); */ 532 540 return len; 533 541 } … … 948 956 int cmd; 949 957 { 958 int status; 950 959 struct sockaddr_in address; 951 960 struct sockaddr_in netmask; -
c/src/libnetworking/pppd/upap.h
rd8a78f4f r0286b9f 77 77 * Timeouts. 78 78 */ 79 #define UPAP_DEFTIMEOUT 3/* Timeout (seconds) for retransmitting req */79 #define UPAP_DEFTIMEOUT 5 /* Timeout (seconds) for retransmitting req */ 80 80 #define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ 81 81 -
c/src/libnetworking/wrapup/Makefile.am
rd8a78f4f r0286b9f 9 9 endif 10 10 11 NET_O_PIECES = kern lib libc net netinet nfs rtems rtems_servers rtems_telnetd pppd modem\12 $(POSIX_PIECES)11 NET_O_PIECES = kern lib libc net netinet nfs rtems rtems_servers \ 12 rtems_telnetd pppd $(POSIX_PIECES) 13 13 OBJS = $(foreach piece, $(NET_O_PIECES), ../$(piece)/$(ARCH)/*.o) 14 14 LIB = $(ARCH)/libnetworking.a -
cpukit/libnetworking/ChangeLog
rd8a78f4f r0286b9f 1 2001-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 1 31 2002-01-21 Ralf Corsepius <corsepiu@faw.uni-ulm.de> 2 32 -
cpukit/libnetworking/Makefile.am
rd8a78f4f r0286b9f 7 7 8 8 SUBDIRS = arpa kern machine sys vm lib libc net netinet nfs rtems \ 9 rtems_servers pppd modemrtems_telnetd rtems_webserver wrapup9 rtems_servers pppd rtems_telnetd rtems_webserver wrapup 10 10 11 11 include_HEADERS = \ -
cpukit/libnetworking/configure.ac
rd8a78f4f r0286b9f 47 47 nfs/Makefile 48 48 pppd/Makefile 49 modem/Makefile50 49 rtems/Makefile 51 50 rtems_servers/Makefile -
cpukit/libnetworking/net/Makefile.am
rd8a78f4f r0286b9f 11 11 12 12 C_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 14 14 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) 15 15 -
cpukit/libnetworking/net/if_ppp.h
rd8a78f4f r0286b9f 39 39 #define SC_LOG_RAWIN 0x00080000 /* log all chars received */ 40 40 #define SC_LOG_FLUSH 0x00100000 /* log all chars flushed */ 41 #define SC_SYNC 0x00200000 /* synchrounous HDLC */42 41 #define SC_RCV_B7_0 0x01000000 /* have rcvd char with bit 7 = 0 */ 43 42 #define SC_RCV_B7_1 0x02000000 /* have rcvd char with bit 7 = 1 */ 44 43 #define SC_RCV_EVNP 0x04000000 /* have rcvd char with even parity */ 45 44 #define SC_RCV_ODDP 0x08000000 /* have rcvd char with odd parity */ 45 #define SC_SYNC 0x00200000 /* use synchronous HDLC framing */ 46 46 #define SC_MASK 0x0fff00ff /* bits that user can change */ 47 47 … … 90 90 */ 91 91 92 #define PPPIOCSTASK _IOW('t', 91, int) /* set pppd task id */ 92 93 #define PPPIOCGFLAGS _IOR('t', 90, int) /* get configuration flags */ 93 94 #define PPPIOCSFLAGS _IOW('t', 89, int) /* set configuration flags */ -
cpukit/libnetworking/net/if_pppvar.h
rd8a78f4f r0286b9f 46 46 * indexing sc_npmode. 47 47 */ 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 50 52 51 53 /* … … 64 66 struct ifqueue sc_inq; /* queue of input packets for daemon */ 65 67 struct ifqueue sc_fastq; /* interactive output packet q */ 66 struct mbuf *sc_togo; /* output packet ready to go */67 68 struct mbuf *sc_npqueue; /* output packets not to be sent yet */ 68 69 struct mbuf **sc_npqtail; /* ptr to last next ptr in npqueue */ … … 85 86 86 87 /* 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; 99 112 }; 100 113 … … 107 120 int pppioctl __P((struct ppp_softc *sc, int cmd, caddr_t data, 108 121 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));111 122 struct mbuf *ppp_dequeue __P((struct ppp_softc *sc)); 123 u_short pppfcs __P((u_short fcs, u_char *cp, int len)); 124 void 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 36 36 */ 37 37 #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 */ 39 39 #endif 40 40 #ifndef DO_DEFLATE 41 #define DO_DEFLATE 1/* by default, include Deflate */41 #define DO_DEFLATE 0 /* by default, include Deflate */ 42 42 #endif 43 43 #define DO_PREDICTOR_1 0 -
cpukit/libnetworking/net/ppp_defs.h
rd8a78f4f r0286b9f 78 78 #define PPP_ATCP 0x8029 /* AppleTalk Control Protocol */ 79 79 #define PPP_IPXCP 0x802b /* IPX Control Protocol */ 80 #define PPP_IPV6CP 0x8057 /* IPv6 Control Protocol */ 80 81 #define PPP_CCP 0x80fd /* Compression Control Protocol */ 81 82 #define PPP_LCP 0xc021 /* Link Control Protocol */ … … 97 98 98 99 #if !defined(__BIT_TYPES_DEFINED__) && !defined(_BITYPES) \ 99 && !defined(__FreeBSD__) && (NS_TARGET < 40) && !defined(__rtems__)100 && !defined(__FreeBSD__) && (NS_TARGET < 40) 100 101 #ifdef UINT32_T 101 102 typedef UINT32_T u_int32_t; 102 103 #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;*/ 105 106 #endif 106 107 #endif -
cpukit/libnetworking/wrapup/Makefile.am
rd8a78f4f r0286b9f 9 9 endif 10 10 11 NET_O_PIECES = kern lib libc net netinet nfs rtems rtems_servers rtems_telnetd pppd modem\12 $(POSIX_PIECES)11 NET_O_PIECES = kern lib libc net netinet nfs rtems rtems_servers \ 12 rtems_telnetd pppd $(POSIX_PIECES) 13 13 OBJS = $(foreach piece, $(NET_O_PIECES), ../$(piece)/$(ARCH)/*.o) 14 14 LIB = $(ARCH)/libnetworking.a -
cpukit/pppd/Makefile.am
rd8a78f4f r0286b9f 11 11 LIB = $(ARCH)/$(LIBNAME) 12 12 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 13 C_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 14 16 C_O_FILES = $(C_FILES:%.c=$(ARCH)/%.o) 15 17 … … 34 36 chat.c demand.c fsm.c fsm.h ipcp.c ipcp.h ipxcp.c ipxcp.h \ 35 37 lcp.c lcp.h magic.c magic.h md4.c md4.h md5.c md5.h options.c \ 36 patchlevel.h pathnames.h pppd.h rtems main.c rtemspppd.c rtemspppd.h\37 sys-rtems.c upap.c upap.h utils.c38 patchlevel.h pathnames.h pppd.h rtemsdialer.h rtemsmain.c rtemspppd.c \ 39 rtemspppd.h sys-rtems.c upap.c upap.h utils.c 38 40 39 include_HEADERS = rtemspppd.h 41 include_HEADERS = rtemspppd.h rtemsdialer.h 40 42 41 43 -
cpukit/pppd/README
rd8a78f4f r0286b9f 21 21 the ABORT commands. Removed some dead code and did a lot of 22 22 testing on a new Coldfire BSP. Version seems to be very stable. 23 24 Update code to use RTEMS pppd network drivers. Now the pppd 25 software is not dependent on using task driven mode. This 26 change improved stablity and performance. This was updated 27 by Mike Siers <mikes@poliac.com>. 23 28 ================================================================= 24 29 -
cpukit/pppd/STATUS
rd8a78f4f r0286b9f 17 17 with this function call. 18 18 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) 19 The pppd code had now been updated to use it's own RTEMS network 20 drivers. This removes the requirement for the task driven termios 21 support. This update has fixed the large packet ping problem. 22 Currently, I do not know of any problems with the port. 25 23 26 24 If you find any other problems or fix some problems, please post your -
cpukit/pppd/chap.h
rd8a78f4f r0286b9f 111 111 * Timeouts. 112 112 */ 113 #define CHAP_DEFTIMEOUT 3/* Timeout time in seconds */113 #define CHAP_DEFTIMEOUT 5 /* Timeout time in seconds */ 114 114 #define CHAP_DEFTRANSMITS 10 /* max # times to send challenge */ 115 115 -
cpukit/pppd/chat.c
rd8a78f4f r0286b9f 157 157 char *phone_num = (char *) 0; 158 158 char *phone_num2 = (char *) 0; 159 static int ttyfd; 159 160 static int timeout = DEFAULT_CHAT_TIMEOUT; 160 161 … … 193 194 char *clean __P((register char *s, int sending)); 194 195 char *expect_strtok __P((char *, char *)); 195 int chatmain __P(( char *));196 int chatmain __P((int, int, char *)); 196 197 197 198 … … 225 226 } 226 227 227 int chatmain(argv) 228 char *argv; 228 int chatmain(int fd, int mode, char *pScript) 229 229 { 230 230 char *arg; … … 232 232 /* initialize exit code */ 233 233 exit_code = 0; 234 ttyfd = fd; 234 235 235 236 if ( debug ) { 236 dbglog("chat_main: %s\n", argv);237 dbglog("chat_main: %s\n", pScript); 237 238 } 238 239 239 240 /* get first expect string */ 240 arg = getnextcommand(& argv);241 arg = getnextcommand(&pScript); 241 242 while (( arg != NULL ) && ( exit_code == 0 )) { 242 243 /* process the expect string */ … … 244 245 if ( exit_code == 0 ) { 245 246 /* get the next send string */ 246 arg = getnextcommand(& argv);247 arg = getnextcommand(&pScript); 247 248 if ( arg != NULL ) { 248 249 /* process the send string */ … … 250 251 251 252 /* get the next expect string */ 252 arg = getnextcommand(& argv);253 arg = getnextcommand(&pScript); 253 254 } 254 255 } 255 256 } 256 257 if ( exit_code ) { 258 exit_code = -exit_code; 259 } 257 ttyfd = (int)-1; 260 258 261 259 return ( exit_code ); -
cpukit/pppd/example/netconfig.h
rd8a78f4f r0286b9f 6 6 7 7 /* external function prototypes */ 8 extern int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, 9 int attaching); 8 extern int rtems_ppp_driver_attach(struct rtems_bsdnet_ifconfig *config, int attaching); 10 9 11 10 /* Default network interface */ … … 14 13 rtems_ppp_driver_attach, /* attach function */ 15 14 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 */ 18 17 NULL, /* Driver supplies hardware address */ 19 18 0 /* Use default driver parameters */ … … 24 23 &netdriver_config, 25 24 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 */ 31 30 0, /* Gateway */ 32 31 0, /* Log host */ -
cpukit/pppd/fsm.c
rd8a78f4f r0286b9f 60 60 f->state = INITIAL; 61 61 f->flags = 0; 62 f->id = 0;/* XXX Start with random id? */62 f->id = 100; /* XXX Start with random id? */ 63 63 f->timeouttime = DEFTIMEOUT; 64 64 f->maxconfreqtransmits = DEFMAXCONFREQS; … … 414 414 if (f->callbacks->up) 415 415 (*f->callbacks->up)(f); /* Inform upper layers */ 416 } else 416 } else { 417 417 f->state = ACKSENT; 418 ppp_delay(); 419 } 418 420 f->nakloops = 0; 419 421 -
cpukit/pppd/fsm.h
rd8a78f4f r0286b9f 120 120 * Timeouts. 121 121 */ 122 #define DEFTIMEOUT 3/* Timeout time in seconds */122 #define DEFTIMEOUT 5 /* Timeout time in seconds */ 123 123 #define DEFMAXTERMREQS 2 /* Maximum Terminate-Request transmissions */ 124 124 #define DEFMAXCONFREQS 10 /* Maximum Configure-Request transmissions */ -
cpukit/pppd/ipcp.c
rd8a78f4f r0286b9f 1571 1571 u_int32_t peerdns1, peerdns2; 1572 1572 { 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(); 1591 1593 } 1592 1594 -
cpukit/pppd/options.c
rd8a78f4f r0286b9f 716 716 if (sv == NULL) 717 717 novm("option argument"); 718 if ( *(char **)(opt->addr) != NULL ) { 719 free((void *)*(char **)(opt->addr)); 720 *(char **)(opt->addr) = NULL; 721 } 718 722 *(char **)(opt->addr) = sv; 719 723 } -
cpukit/pppd/pppd.h
rd8a78f4f r0286b9f 20 20 */ 21 21 22 /*23 * TODO:24 */25 26 22 #ifndef __PPPD_H__ 27 23 #define __PPPD_H__ … … 33 29 #include <sys/time.h> /* for struct timeval */ 34 30 #include <net/ppp_defs.h> 31 #include "rtemsdialer.h" 35 32 36 33 #if defined(__STDC__) … … 168 165 extern int do_callback; /* set if we want to do callback next */ 169 166 extern int doing_callback; /* set if this is a callback */ 167 extern dialerfp pppd_dialer; /* script dialer function callback */ 170 168 171 169 /* Values for do_callback and doing_callback */ … … 379 377 void setdtr __P((int, int)); /* Raise or lower port's DTR line */ 380 378 void output __P((int, u_char *, int)); /* Output a PPP packet */ 381 void wait_input __P((struct timeval *)); 382 /* Wait for input, with timeout */ 379 void wait_input __P((struct timeval *)); /* Wait for input, with timeout */ 380 381 void ppp_delay __P((void)); /* delay task for a little while */ 383 382 int read_packet __P((u_char *)); /* Read PPP packet */ 384 383 int get_loop_output __P((void)); /* Read pkts from loopback */ -
cpukit/pppd/rtemsmain.c
rd8a78f4f r0286b9f 42 42 #include <rtems.h> 43 43 #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);47 44 48 45 #include "pppd.h" … … 59 56 #include "pathnames.h" 60 57 #include "patchlevel.h" 58 #include "rtemsdialer.h" 61 59 62 60 #ifdef CBCP_SUPPORT … … 95 93 int doing_callback; /* != 0 if we are doing callback */ 96 94 char *callback_script; /* script for doing callback */ 95 dialerfp pppd_dialer; 97 96 98 97 int (*holdoff_hook) __P((void)) = NULL; … … 130 129 static struct timeval *timeleft __P((struct timeval *)); 131 130 static void holdoff_end __P((void *)); 132 static int device_script __P(( char *, int, int, int));131 static int device_script __P((int, int, char *)); 133 132 134 133 extern char *ttyname __P((int)); … … 313 312 314 313 if (initializer && initializer[0]) { 315 if (device_script( initializer, ttyfd, ttyfd, 0) < 0) {314 if (device_script(ttyfd, DIALER_INIT, initializer) < 0) { 316 315 error("Initializer script failed"); 317 316 status = EXIT_INIT_FAILED; … … 325 324 326 325 if (connector && connector[0]) { 327 if (device_script( connector, ttyfd, ttyfd, 0) < 0) {326 if (device_script(ttyfd, DIALER_CONNECT, connector) < 0) { 328 327 error("Connect script failed"); 329 328 status = EXIT_CONNECT_FAILED; … … 365 364 /* run welcome script, if any */ 366 365 if (welcomer && welcomer[0]) { 367 if (device_script( welcomer, ttyfd, ttyfd, 0) < 0)366 if (device_script(ttyfd, DIALER_WELCOME, welcomer) < 0) 368 367 warn("Welcome script failed"); 369 368 } … … 388 387 gettimeofday(&start_time, NULL); 389 388 390 rtems_bsdnet_semaphore_obtain();391 389 lcp_lowerup(0); 392 390 lcp_open(0); /* Start protocol */ 393 rtems_bsdnet_semaphore_release();394 391 395 392 open_ccp_flag = 0; … … 399 396 wait_input(timeleft(&timo)); 400 397 calltimeout(); 401 398 get_input(); 402 399 403 400 if (kill_link) { … … 436 433 if (real_ttyfd >= 0) 437 434 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) { 439 436 warn("disconnect script failed"); 440 437 } else { … … 478 475 479 476 die(status); 480 return 0;477 return status; 481 478 } 482 479 … … 579 576 */ 580 577 static void 581 get_input( )578 get_input(void) 582 579 { 583 580 int len, i; … … 609 606 } 610 607 611 rtems_bsdnet_semaphore_obtain();612 608 p += 2; /* Skip address and control */ 613 609 GETSHORT(protocol, p); … … 619 615 if (protocol != PPP_LCP && lcp_fsm[0].state != OPENED) { 620 616 MAINDEBUG(("get_input: Received non-LCP packet when LCP not open.")); 621 rtems_bsdnet_semaphore_release();622 617 return; 623 618 } … … 632 627 MAINDEBUG(("get_input: discarding proto 0x%x in phase %d", 633 628 protocol, phase)); 634 rtems_bsdnet_semaphore_release();635 629 return; 636 630 } … … 642 636 if (protp->protocol == protocol && protp->enabled_flag) { 643 637 (*protp->input)(0, p, len); 644 rtems_bsdnet_semaphore_release();645 638 return; 646 639 } … … 648 641 && protp->datainput != NULL) { 649 642 (*protp->datainput)(0, p, len); 650 rtems_bsdnet_semaphore_release();651 643 return; 652 644 } … … 661 653 } 662 654 lcp_sprotrej(0, p - PPP_HDRLEN, len + PPP_HDRLEN); 663 rtems_bsdnet_semaphore_release(); 655 656 return; 664 657 } 665 658 … … 873 866 * (e.g. to run the connector or disconnector script). 874 867 */ 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 868 static 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 */ 883 874 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 ); 885 889 } 886 890 -
cpukit/pppd/rtemspppd.c
rd8a78f4f r0286b9f 1 1 2 2 #include <rtems.h> 3 #include <rtems/rtems_bsdnet.h> 3 4 #include "pppd.h" 4 5 #include "rtemspppd.h" … … 7 8 /* define pppd function prototypes */ 8 9 extern void pppasyncattach(void); 9 extern int pppdmain(int, char **);10 extern int pppdmain(int, char **); 10 11 11 12 /* define global variables */ 12 rtems_id rtems_pppd_taskid; 13 rtems_id rtems_pppd_taskid; 14 rtems_pppd_hookfunction rtems_pppd_errorfp; 15 rtems_pppd_hookfunction rtems_pppd_exitfp; 13 16 14 17 … … 19 22 rtems_event_set in; 20 23 rtems_event_set out; 24 int iStatus; 21 25 22 26 /* call function to setup ppp line discipline */ … … 39 43 /* connect request */ 40 44 /* 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 } 42 58 } 43 59 } … … 45 61 46 62 /* terminate myself */ 63 rtems_pppd_taskid = 0; 47 64 rtems_task_delete(RTEMS_SELF); 48 65 } … … 50 67 int rtems_pppd_initialize(void) 51 68 { 52 int iReturn = (int)-1; 69 int iReturn = (int)-1; 70 rtems_unsigned32 priority = 100; 53 71 rtems_status_code status; 54 72 rtems_name taskName; 55 73 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 */ 56 83 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, 62 87 &rtems_pppd_taskid); 63 88 if ( status == RTEMS_SUCCESSFUL ) { … … 115 140 ip_down_hook = hookfp; 116 141 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; 117 148 default: 118 149 iReturn = (int)-1; … … 121 152 122 153 return ( iReturn ); 154 } 155 156 int rtems_pppd_set_dialer(rtems_pppd_dialerfunction dialerfp) 157 { 158 pppd_dialer = dialerfp; 159 return ( (int)0 ); 123 160 } 124 161 -
cpukit/pppd/rtemspppd.h
rd8a78f4f r0286b9f 3 3 #define RTEMSPPPD_H 4 4 5 /* check to see if pppd task values are set */6 #ifndef RTEMS_PPPD_TASK_PRIORITY7 #define RTEMS_PPPD_TASK_PRIORITY 1208 #endif9 #ifndef RTEMS_PPPD_TASK_STACK_SIZE10 #define RTEMS_PPPD_TASK_STACK_SIZE (10*1024)11 #endif12 #ifndef RTEMS_PPPD_TASK_INITIAL_MODES13 #define RTEMS_PPPD_TASK_INITIAL_MODES (RTEMS_PREEMPT | \14 RTEMS_NO_TIMESLICE | \15 RTEMS_NO_ASR | \16 RTEMS_INTERRUPT_LEVEL(0))17 #endif18 5 19 6 /* define hook function identifiers */ … … 22 9 #define RTEMS_PPPD_IPUP_HOOK 3 23 10 #define RTEMS_PPPD_IPDOWN_HOOK 4 11 #define RTEMS_PPPD_ERROR_HOOK 5 12 #define RTEMS_PPPD_EXIT_HOOK 6 24 13 25 14 /* define hook function pointer prototype */ 26 15 typedef void (*rtems_pppd_hookfunction)(void); 16 typedef int (*rtems_pppd_dialerfunction)(int tty, int mode, char *pScript); 27 17 28 18 … … 32 22 int rtems_pppd_reset_options(void); 33 23 int rtems_pppd_set_hook(int id, rtems_pppd_hookfunction hookfp); 24 int rtems_pppd_set_dialer(rtems_pppd_dialerfunction dialerfp); 34 25 int rtems_pppd_set_option(const char *pOption, const char *pValue); 35 26 int rtems_pppd_connect(void); -
cpukit/pppd/sys-rtems.c
rd8a78f4f r0286b9f 96 96 97 97 98 void99 sys_serialcallback(struct termios *tty, void *arg)100 {101 rtems_event_send(rtems_pppd_taskid, RTEMS_EVENT_31);102 }103 104 98 /* 105 99 * sys_init - System-dependent initialization. … … 188 182 int fd; 189 183 { 184 int taskid = (int)rtems_pppd_taskid; 190 185 int pppdisc = PPPDISC; 191 186 int x; … … 206 201 if (ioctl(fd, TIOCSETD, &pppdisc) < 0) 207 202 fatal("ioctl(TIOCSETD): %m"); 203 204 /* set pppd taskid into the driver */ 205 ioctl(fd, PPPIOCSTASK, &taskid); 208 206 209 207 if (!demand) { … … 287 285 int fd; 288 286 { 287 int taskid = (int)0; 288 289 /* clear pppd taskid from the driver */ 290 ioctl(fd, PPPIOCSTASK, &taskid); 291 289 292 /* Reset non-blocking mode on fd. */ 290 293 if (initfdflags != -1 && fcntl(fd, F_SETFL, initfdflags) < 0) … … 345 348 { 346 349 struct termios tios; 347 struct ttywakeup wakeup;348 350 349 351 if (tcgetattr(fd, &tios) < 0) … … 403 405 fatal("tcsetattr: %m"); 404 406 } 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);410 407 411 408 restore_term = 1; … … 490 487 if (debug); 491 488 dbglog("sent %P", p, len); 489 /* printf("sent packet [%d]\n", len); */ 492 490 493 491 if (write(ttyfd, p, len) < 0) { … … 497 495 } 498 496 497 void 498 ppp_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 } 499 506 500 507 /* … … 526 533 527 534 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; 530 536 /*fatal("read: %m"); */ 531 537 } 538 539 /* printf("read packet [%d]\n", len); */ 532 540 return len; 533 541 } … … 948 956 int cmd; 949 957 { 958 int status; 950 959 struct sockaddr_in address; 951 960 struct sockaddr_in netmask; -
cpukit/pppd/upap.h
rd8a78f4f r0286b9f 77 77 * Timeouts. 78 78 */ 79 #define UPAP_DEFTIMEOUT 3/* Timeout (seconds) for retransmitting req */79 #define UPAP_DEFTIMEOUT 5 /* Timeout (seconds) for retransmitting req */ 80 80 #define UPAP_DEFREQTIME 30 /* Time to wait for auth-req from peer */ 81 81
Note: See TracChangeset
for help on using the changeset viewer.