source: rtems/cpukit/pppd/rtemspppd.c @ 2f1b930

4.104.114.84.9
Last change on this file since 2f1b930 was 2f1b930, checked in by Joel Sherrill <joel.sherrill@…>, on Aug 16, 2001 at 8:42:09 PM

2001-08-16 Mike Siers <mikes@…>

  • Update of PPPD to 2.3.11 from 2.3.5 and addition of an example application. Mike's notes on the modifications:
    • renamed error() function because of namespace problems
    • removed calls to the exit() funciton
    • removed extra files from the pppd source directory
    • defined pppd task constant values in rtemspppd.h
    • modifyied example code to get actual tick per second value
    • placed the pppd 2.3.11 man page file (pppd.8) into the pppd directory
  • pppd/cbcp.c, pppd/cbcp.h, pppd/main.c, pppd/ppp_tty.c, pppd/pppmain.c, pppd/rtems-ppp.c, pppd/rtems-ppp.c: Deleted.
  • pppd/pppd.8, pppd/rtemsmain.c, pppd/rtemspppd.c, pppd/rtemspppd.h, pppd/sys-rtems.c, pppd/utils.c, pppd/example/Makefile, pppd/example/README, pppd/example/init.c, pppd/example/netconfig.h, pppd/example/ppp.conf, pppd/example/pppdapp.c, pppd/example/system.h: New files.
  • modem/ppp_tty.c, net/if_ppp.h, pppd/Makefile.am, pppd/README, pppd/STATUS, pppd/auth.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.h, pppd/upap.c, pppd/upap.h: Modified.
  • Property mode set to 100644
File size: 4.1 KB
Line 
1
2#include <rtems.h>
3#include "pppd.h"
4#include "rtemspppd.h"
5
6
7/* define pppd function prototypes */
8extern void pppasyncattach(void);
9extern int pppdmain(int, char **);
10
11/* define global variables */
12rtems_id rtems_pppd_taskid;
13
14
15static rtems_task pppTask(rtems_task_argument arg)
16{
17  rtems_status_code   sc = RTEMS_SUCCESSFUL;
18  rtems_option        options;
19  rtems_event_set     in;
20  rtems_event_set     out;
21
22  /* call function to setup ppp line discipline */
23  pppasyncattach();
24
25  /* enter processing loop */
26  in      = (RTEMS_EVENT_29 | RTEMS_EVENT_30);
27  options = (RTEMS_EVENT_ANY | RTEMS_WAIT);
28  while ( sc == RTEMS_SUCCESSFUL ) {
29    /* wait for the next event */
30    sc = rtems_event_receive(in, options, RTEMS_NO_TIMEOUT, &out);
31    if ( sc == RTEMS_SUCCESSFUL ) {
32      /* determine which event was sent */
33      if ( out & RTEMS_EVENT_29 ) {
34        /* terminate event received */
35        /* set value to break out of event loop */
36        sc = RTEMS_UNSATISFIED;
37      }
38      else if ( out & RTEMS_EVENT_30 ) {
39        /* connect request */
40        /* execute the pppd main code */
41        pppdmain(0, NULL);
42      }
43    }
44  }
45
46  /* terminate myself */
47  rtems_task_delete(RTEMS_SELF);
48}
49
50int rtems_pppd_initialize(void)
51{
52  int                 iReturn = (int)-1;
53  rtems_status_code   status;
54  rtems_name          taskName;
55
56  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,
62                               &rtems_pppd_taskid);
63  if ( status == RTEMS_SUCCESSFUL ) {
64    status = rtems_task_start(rtems_pppd_taskid, pppTask, 0);
65    if ( status == RTEMS_SUCCESSFUL ) {
66      iReturn = rtems_pppd_reset_options();
67    }
68  }
69
70  return ( iReturn );
71}
72
73int rtems_pppd_terminate(void)
74{
75  /* send terminate signal to pppd task */
76  rtems_event_send(rtems_pppd_taskid, RTEMS_EVENT_29);
77
78  /* call the disconnect function */
79  rtems_pppd_disconnect();
80
81  return ( 0 );
82}
83
84int rtems_pppd_reset_options(void)
85{
86    int i;
87    struct protent *protp;
88
89    /*
90     * Initialize to the standard option set, then parse, in order,
91     * the system options file, the user's options file,
92     * the tty's options file, and the command line arguments.
93     */
94    for (i = 0; (protp = protocols[i]) != NULL; ++i)
95        (*protp->init)(0);
96
97  return ( 0 );
98}
99
100int rtems_pppd_set_hook(int id, rtems_pppd_hookfunction hookfp)
101{
102  int     iReturn = (int)0;
103
104  switch ( id ) {
105  case RTEMS_PPPD_LINKUP_HOOK:
106    auth_linkup_hook = hookfp;
107    break;
108  case RTEMS_PPPD_LINKDOWN_HOOK:
109    auth_linkdown_hook = hookfp;
110    break;
111  case RTEMS_PPPD_IPUP_HOOK:
112    ip_up_hook = hookfp;
113    break;
114  case RTEMS_PPPD_IPDOWN_HOOK:
115    ip_down_hook = hookfp;
116    break;
117  default:
118    iReturn = (int)-1;
119    break;
120  }
121
122  return ( iReturn );
123}
124
125int rtems_pppd_set_option(const char *pOption, const char *pValue)
126{
127  int                iReturn = (int)0;
128  int                prevPhase;
129  struct wordlist    option;
130  struct wordlist    value;
131
132  if ( pOption != (const char *)0 ) {
133    /* initialize the values */
134    option.word = (char *)pOption;
135    option.next = (struct wordlist *)0;
136    if ( pValue != (const char *)0 ) {
137      option.next = &value;
138      value.word  = (char *)pValue;
139      value.next  = (struct wordlist *)0;
140    }
141
142    /* save current phase value */
143    prevPhase = phase;
144    phase     = PHASE_INITIALIZE;
145
146    /* process option and reset phase value */
147    iReturn = options_from_list(&option, 1);
148    phase   = prevPhase;
149  }
150
151  return ( iReturn );
152}
153
154int rtems_pppd_connect(void)
155{
156  /* send connect signal to pppd task */
157  rtems_event_send(rtems_pppd_taskid, RTEMS_EVENT_30);
158
159  return ( 0 );
160}
161
162int rtems_pppd_disconnect(void)
163{
164  /* set pppd global variables to disconnect */
165  persist   = 0;
166  kill_link = 1;
167
168  /* send event to wake up the pppd code */
169  /* pretend its a serial interrput */
170  rtems_event_send(rtems_pppd_taskid, RTEMS_EVENT_31);
171
172  return ( 0 );
173}
Note: See TracBrowser for help on using the repository browser.