/* * Called from boot code to establish ppp interfaces. */ static void pppattach(void *dummy) { struct ppp_softc *sc; int i = 0; for (sc = ppp_softc; i < NPPP; sc++) { if_initname(&(sc->sc_if), "ppp", i++); sc->sc_if.if_softc = sc; sc->sc_if.if_mtu = PPP_MTU; sc->sc_if.if_flags = IFF_POINTOPOINT | IFF_MULTICAST; sc->sc_if.if_type = IFT_PPP; sc->sc_if.if_hdrlen = PPP_HDRLEN; sc->sc_if.if_ioctl = pppsioctl; sc->sc_if.if_output = pppoutput; sc->sc_if.if_start = ppp_ifstart; ifq_set_maxlen(&sc->sc_if.if_snd, IFQ_MAXLEN); ifq_set_ready(&sc->sc_if.if_snd); sc->sc_inq.ifq_maxlen = IFQ_MAXLEN; sc->sc_fastq.ifq_maxlen = IFQ_MAXLEN; sc->sc_rawq.ifq_maxlen = IFQ_MAXLEN; callout_init(&sc->sc_timeout); if_attach(&sc->sc_if, NULL); bpfattach(&sc->sc_if, DLT_PPP, PPP_HDRLEN); } netisr_register(NETISR_PPP, pppintr, NULL); /* * XXX layering violation - if_ppp can work over any lower level * transport that cares to attach to it. */ pppasyncattach(dummy); }
static rtems_task pppTask(rtems_task_argument arg) { rtems_status_code sc = RTEMS_SUCCESSFUL; rtems_option options; rtems_event_set in; rtems_event_set out; int iStatus; /* call function to setup ppp line discipline */ pppasyncattach(); /* enter processing loop */ in = (RTEMS_EVENT_29 | RTEMS_EVENT_30); options = (RTEMS_EVENT_ANY | RTEMS_WAIT); while ( sc == RTEMS_SUCCESSFUL ) { /* wait for the next event */ sc = rtems_event_receive(in, options, RTEMS_NO_TIMEOUT, &out); if ( sc == RTEMS_SUCCESSFUL ) { /* determine which event was sent */ if ( out & RTEMS_EVENT_29 ) { /* terminate event received */ /* set value to break out of event loop */ sc = RTEMS_UNSATISFIED; } else if ( out & RTEMS_EVENT_30 ) { /* connect request */ /* execute the pppd main code */ iStatus = pppdmain(0, NULL); if ( iStatus == EXIT_OK ) { /* check exit callback */ if ( rtems_pppd_exitfp ) { (*rtems_pppd_exitfp)(); } } else { /* check error callback */ if ( rtems_pppd_errorfp ) { (*rtems_pppd_errorfp)(); } } } } } /* terminate myself */ rtems_pppd_taskid = 0; rtems_task_delete(RTEMS_SELF); }
rtems_task Init( rtems_task_argument argument ) { TEST_BEGIN(); pppasyncattach(); open_it(); set_wakeups(); set_discipline(); write_it(); ioctl_it(); read_it(); close_it(); TEST_END(); rtems_test_exit(0); }