OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [net/] [ppp/] [current/] [doc/] [ppp.sgml] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
2
 
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
 
28
29
 
30
 
31
32
<productname>eCos</productname> PPP User Guide
33
 
34
35
36
This package provides support for PPP (Point-to-Point Protocol) in the
37
eCos FreeBSD TCP/IP networking stack.
38
39
40
 
41
42
 
43
44
Features
45
46
The eCos PPP implementation provides the
47
following features:
48
49
50
 
51
52
53
PPP line protocol including VJ compression.
54
55
56
 
57
58
59
LCP, IPCP and CCP control protocols.
60
61
62
 
63
64
65
PAP and CHAP authentication.
66
67
68
 
69
70
71
CHAT subset connection scripting.
72
73
74
 
75
76
77
Modem control line support.
78
79
80
 
81
82
83
 
84
85
86
 
87
88
Using PPP
89
90
Before going into detail, let's look at a simple example of how the
91
eCos PPP package is used. Consider the
92
following example:
93
94
 
95
96
static void ppp_up(void)
97
{
98
    cyg_ppp_options_t options;
99
    cyg_ppp_handle_t ppp_handle;
100
 
101
    // Bring up the TCP/IP network
102
    init_all_network_interfaces();
103
 
104
    // Initialize the options
105
    cyg_ppp_options_init( &options );
106
 
107
    // Start up PPP
108
    ppp_handle = cyg_ppp_up( "/dev/ser0", &options );
109
 
110
    // Wait for it to get running
111
    if( cyg_ppp_wait_up( ppp_handle ) == 0 )
112
    {
113
        // Make use of PPP
114
        use_ppp();
115
 
116
        // Bring PPP link down
117
        cyg_ppp_down( ppp_handle );
118
 
119
        // Wait for connection to go down.
120
        cyg_ppp_wait_down( ppp_handle );
121
    }
122
}
123
124
 
125
126
This is a simple example of how to bring up a simple PPP connection to
127
another computer over a directly connected serial line. The other end
128
is assumed to already be running PPP on the line and waiting for a
129
connection.
130
131
 
132
133
The first thing this code does is to call
134
init_all_network_interfaces() to bring up the
135
TCP/IP stack and initialize any other network interfaces. It then
136
calls cyg_ppp_options_init() to initialize the
137
PPP options structure to the defaults. As it happens, the default
138
options are exactly what we want for this example, so we don't need to
139
make any further changes. We go straight on to bring the PPP interface
140
up by calling cyg_ppp_up(). The arguments to this
141
function give the name of the serial device to use, in this case
142
"/dev/ser0", and a pointer to the options.
143
144
 
145
146
When cyg_ppp_up() returns, it passes back a
147
handle to the PPP connection which is to be used in other calls.  The
148
PPP link will not necessarily have been fully initialized at this
149
time. There is a certain amount of negotiation that goes on between
150
the ends of a PPP link before it is ready to pass packets. An
151
application can wait until the link is ready by calling
152
cyg_ppp_wait_up(), which returns
153
zero if the link is up and running, or
154
-1 if it has gone down or failed to come up.
155
156
 
157
158
After a successful return from cyg_ppp_wait_up(),
159
the application may make use of the PPP connection. This is
160
represented here by the call to use_ppp() but
161
it may, of course, be accessed by any thread. While the connection is
162
up the application may use the standard socket calls to make or accept
163
network connections and transfer data in the normal way.
164
165
 
166
167
Once the application has finished with the PPP link, it can bring it
168
down by calling cyg_ppp_down(). As with bringing
169
the connection up, this call is asynchronous, it simply informs the
170
PPP subsystem to start bringing the link down. The application can
171
wait for the link to go down fully by calling
172
cyg_ppp_wait_down().
173
174
 
175
176
That example showed how to use PPP to connect to a local peer. PPP is
177
more often used to connect via a modem to a remote server, such as an
178
ISP. The following example shows how this works:
179
180
 
181
182
 
183
static char *isp_script[] =
184
{
185
    "ABORT"             ,       "BUSY"                                  ,
186
    "ABORT"             ,       "NO CARRIER"                            ,
187
    "ABORT"             ,       "ERROR"                                 ,
188
    ""                  ,       "ATZ"                                   ,
189
    "OK"                ,       "AT S7=45 S0=0 L1 V1 X4 &C1 E1 Q0"      ,
190
    "OK"                ,       "ATD" CYGPKG_PPP_DEFAULT_DIALUP_NUMBER  ,
191
    "ogin:--ogin:"      ,       CYGPKG_PPP_AUTH_DEFAULT_USER            ,
192
    "assword:"          ,       CYGPKG_PPP_AUTH_DEFAULT_PASSWD          ,
193
    "otocol:"           ,       "ppp"                                   ,
194
    "HELLO"             ,       "\\c"                                   ,
195
 
196
};
197
 
198
static void ppp_up(void)
199
{
200
    cyg_ppp_options_t options;
201
    cyg_ppp_handle_t ppp_handle;
202
 
203
    // Bring up the TCP/IP network
204
    init_all_network_interfaces();
205
 
206
    // Initialize the options
207
    cyg_ppp_options_init( &options );
208
 
209
    options.script = isp_script;
210
    options.modem  = 1;
211
 
212
    // Start up PPP
213
    ppp_handle = cyg_ppp_up( "/dev/ser0", &options );
214
 
215
    // Wait for it to get running
216
    if( cyg_ppp_wait_up( ppp_handle ) == 0 )
217
    {
218
        // Make use of PPP
219
        use_ppp();
220
 
221
        // Bring PPP link down
222
        cyg_ppp_down( ppp_handle );
223
 
224
        // Wait for connection to go down.
225
        cyg_ppp_wait_down( ppp_handle );
226
    }
227
}
228
229
 
230
231
The majority of this code is exactly the same as the previous
232
example. The main difference is in the setting of a couple of options
233
before calling cyg_ppp_up(). The
234
script option is set to point to a CHAT
235
script to manage the setup of the connection. The
236
modem option is set to cause the PPP system
237
to make use of the modem control lines.
238
239
 
240
241
During the PPP bring-up a call will be made to
242
cyg_ppp_chat() to run the CHAT script (see 
243
linkend="ppp-chat">). In the example this script sets up various modem
244
options and then dials a number supplied as part of the PPP package
245
configuration (see ). When the connection
246
has been established, the script log on to the server, using a name
247
and password also supplied by the configuration, and then starts PPP
248
on the remote end. If this script succeeds the PPP connection will be
249
brought up and will then function as expected.
250
251
 
252
253
The modem option causes the PPP system to
254
make use of the modem control lines. In particular it waits for
255
Carrier Detect to be asserted, and will bring the
256
link down if it is lost. See 
257
for more details.
258
259
 
260
261
 
262
263
264
 
265
266
PPP Interface
267
 
268
269
 
270
271
 
272
    
273
    cyg_ppp_options_init()
274
    
275
 
276
    
277
      cyg_ppp_options_init
278
      Initialize PPP link options
279
    
280
 
281
    
282
      
283
        
284
#include <cyg/ppp/ppp.h>
285
        
286
        
287
          cyg_int32 cyg_ppp_options_init
288
          cyg_ppp_options_t *options
289
        
290
      
291
    
292
 
293
    Description
294
295
This function initializes the PPP options, pointed to by the
296
options parameter, to the default state. Once
297
the defaults have been initialized, application code may adjust them
298
by assigning new values to the the fields of the
299
cyg_ppp_options_t structure.
300
301
 
302
303
This function returns zero if the options were initialized
304
successfully. It returns -1 if the options
305
argument is NULL, or the options could not be initialized.
306
307
 
308
309
The option fields, their functions and default values are as follows:
310
311
 
312
313
 
314
315
  debug
316
  
317
     If set to 1 this enables the reporting of debug messages
318
    from the PPP system. These will be generated using
319
    diag_printf() and will appear on the standard
320
    debug channel. Note that diag_printf()
321
    disables interrupts during output: this may cause the PPP link
322
    device to overrun and miss characters. It is quite possible for
323
    this option to cause errors and even make the PPP link fail
324
    completely. Consequently, this option should be used with care.
325
    
326
    
327
    Default value: 0
328
    
329
  
330
331
 
332
333
  kdebugflag
334
  
335
     This five bit field enables low level debugging messages from
336
    the PPP device layer in the TCP/IP stack. As with the
337
    debug option, this may result in missed
338
    characters and cause errors. The bits of the field have the
339
    following meanings:
340
    
341
    
342
      
343
        
344
          
345
            Bit
346
            BSD Name
347
            Description
348
          
349
        
350
        
351
          
352
            0x01
353
            SC_DEBUG
354
            Enable debug messages
355
          
356
          
357
            0x02
358
            SC_LOG_INPKT
359
            Log contents of good packets received
360
          
361
          
362
            0x04
363
            SC_LOG_OUTPKT
364
            Log contents of packets sent
365
          
366
          
367
            0x08
368
            SC_LOG_RAWIN
369
            Log all characters received
370
          
371
          
372
            0x10
373
            SC_LOG_FLUSH
374
            Log all characters flushed
375
          
376
        
377
      
378
    
379
    
380
    Default value: 0
381
    
382
  
383
384
 
385
386
  default_route
387
  
388
     If set to 1 this option causes the PPP subsystem to install
389
    a default route in the TCP/IP stack's routing tables using the
390
    peer as the gateway. This entry will be removed when the PPP link
391
    is broken. If there is already an existing working network
392
    connection, such as an ethernet device, then there may already be
393
    a default route established. If this is the case, then this option
394
    will have no effect.
395
    
396
    
397
    Default value: 1
398
    
399
  
400
401
 
402
403
  modem
404
  
405
     If this option is set to 1, then the modem lines will be
406
    used during the connection. Specifically, the PPP subsystem will
407
    wait until the carrier detect signal is
408
    asserted before bringing up the PPP link, and will take the PPP
409
    link down if this signal is de-asserted.
410
    
411
    
412
    Default value: 0
413
    
414
  
415
416
 
417
418
  flowctl
419
  
420
     This option is used to specify the mechanism used to
421
    control data flow across the serial line. It can take one of the
422
    following values:
423
    
424
    
425
      
426
        CYG_PPP_FLOWCTL_DEFAULT
427
        
428
          
429
          The flow control mechanism is not changed and is left at
430
          whatever value was set before bringing PPP up. This allows
431
          a non-standard flow control mechanism to be used, or for it to
432
          be chosen and set by some other means.
433
          
434
        
435
      
436
      
437
        CYG_PPP_FLOWCTL_NONE
438
        
439
          
440
          Flow control is turned off. It is not recommended that this
441
          option be used unless the baud rate is set low or the two
442
          communicating machines are particularly fast.
443
          
444
        
445
      
446
      
447
        CYG_PPP_FLOWCTL_HARDWARE
448
        
449
          
450
          Use hardware flow control via the RTS/CTS lines. This is the
451
          most effective flow control mechanism and should always be
452
          used if available. Availability of this mechanism depends on
453
          whether the serial device hardware has the ability to control
454
          these lines, whether they have been connected to the socket
455
          pins and whether the device driver has the necessary support.
456
          
457
        
458
      
459
      
460
        CYG_PPP_FLOWCTL_SOFTWARE
461
        
462
          
463
          Use software flow control by embedding XON/XOFF characters in
464
          the data stream. This is somewhat less effective that hardware
465
          flow control since it is subject to the propagation time of
466
          the serial cable and the latency of the communicating
467
          devices. Since it does not rely on any hardware support, this
468
          flow control mechanism is always available.
469
          
470
        
471
      
472
    
473
    
474
    Default value: CYG_PPP_FLOWCTL_HARDWARE
475
    
476
  
477
478
 
479
480
  refuse_pap
481
  
482
     If this option is set to 1, then the PPP subsystem will not
483
    agree to authenticate itself to the peer with PAP. When dialling
484
    in to a remote server it is normal to authenticate the
485
    client. There are three ways this can be done, using a
486
    straightforward login mechanism via the CHAT script, with the
487
    Password Authentication Protocol (PAP), or with the Challenge
488
    Handshake Authentication Protocol (CHAP). For PAP to work the
489
    user and
490
    passwd options must be set to the
491
    expected values. If they are not, then this option should be set
492
    to force CHAP authentication.
493
    
494
    
495
    Default value: 0
496
    
497
  
498
499
 
500
501
  refuse_chap
502
  
503
     If this option is set to 1, then the PPP subsystem will not
504
    agree to authenticate itself to the peer with CHAP. CHAP
505
    authentication will only work if the
506
    passwd option has been set to the
507
    required CHAP secret for the destination server. Otherwise this
508
    option should be disabled.
509
    
510
    
511
    If both refuse_pap and
512
    refuse_chap are set, then either no
513
    authentication will be carried out, or it is the responsibility of
514
    the chat script to do it. If the peer does not
515
    require any authentication, then the setting of these options is
516
    irrelevant.
517
    
518
    
519
    Default value: 0
520
    
521
  
522
523
 
524
525
  baud
526
  
527
     This option is set to the baud rate at which the serial
528
    connection should be run. The default value is the rate at which
529
    modems conventionally operate. This field is an instance of the
530
    cyg_serial_baud_rate_t enum defined in the
531
    serialio.h header and may only take one of the
532
    baud rate constants defined in there.
533
    
534
    
535
    Default value: CYGNUM_SERIAL_BAUD_115200
536
    
537
  
538
539
 
540
541
  idle_time_limit
542
  
543
     This is the number of seconds that the PPP connection may
544
    be idle before it is shut down automatically.
545
    
546
    
547
    Default value: 60
548
    
549
  
550
551
 
552
553
  maxconnect
554
  
555
     This causes the connection to terminate when it has been up
556
    for this number of seconds. The default value of zero means that
557
    the connection will stay up indefinitely, until either end
558
    explicitly brings it down, or the link is lost.
559
    
560
    
561
    Default value: 0
562
    
563
  
564
565
 
566
567
  our_address
568
  
569
     This is the IP address, in network byte order, to be
570
    attached to the local end of the PPP connection. The default value
571
    of INADDR_ANY causes the local address to be
572
    obtained from the peer.
573
    
574
    
575
    Default value: INADDR_ANY
576
    
577
  
578
579
 
580
581
  his_address
582
  
583
     This is the IP address, in network byte order, to be
584
    attached to the remote end of the PPP connection. The default
585
    value of INADDR_ANY causes the remote address
586
    to be obtained from the peer.
587
    
588
    
589
    Default value: INADDR_ANY
590
    
591
  
592
593
 
594
595
  script
596
  
597
     This is a pointer to a CHAT script suitable for passing to
598
    cyg_ppp_chat(). See 
599
    for details of the format and contents of this script.
600
    
601
    
602
    Default value: NULL
603
    
604
  
605
606
 
607
608
  user
609
  
610
     This array contains the user name to be used for PAP
611
    authentication. This field is not used for CHAP authentication. By
612
    default the value of this option is set from the
613
    CYGPKG_PPP_AUTH_DEFAULT_USER configuration
614
    option.
615
    
616
    
617
    Default value: CYGPKG_PPP_AUTH_DEFAULT_USER
618
    
619
  
620
621
 
622
623
  passwd
624
  
625
     This array contains the password to be used for PAP
626
    authentication, or the secret to be used during CHAP
627
    authentication. By default the value of this option is set from
628
    the CYGPKG_PPP_AUTH_DEFAULT_PASSWD
629
    configuration option.
630
    
631
    
632
    Default value: CYGPKG_PPP_AUTH_DEFAULT_PASSWD
633
    
634
  
635
636
 
637
638
 
639
    
640
 
641
642
 
643
644
645
 
646
647
 
648
    
649
    cyg_ppp_up()
650
    
651
 
652
    
653
      cyg_ppp_up
654
      Bring PPP connection up
655
    
656
 
657
    
658
      
659
        
660
#include <cyg/ppp/ppp.h>
661
        
662
        
663
          cyg_ppp_handle_t cyg_ppp_up
664
          char *devnam
665
          const cyg_ppp_options_t *options
666
        
667
      
668
    
669
 
670
    Description
671
672
This function starts up a PPP connection. The
673
devnam argument is the name of the device to be
674
used for the connection, typically "/dev/ser0" or
675
"/dev/ser1". The options
676
argument should point to an initialized
677
cyg_ppp_options_t object.
678
679
 
680
681
The return value will either be zero, indicating a failure, or a
682
cyg_ppp_handle_t object that may be used as an argument
683
to other PPP functions.
684
685
 
686
687
688
Although the PPP API is designed to permit several simultaneous
689
connections to co-exist, at present only one PPP connection is
690
actually implemented. Any attempt to create a second connection while
691
there is already one open will fail.
692
693
694
 
695
696
 
697
698
 
699
700
701
 
702
703
 
704
    
705
    cyg_ppp_down()
706
    
707
 
708
    
709
      cyg_ppp_down
710
      Bring PPP connection down
711
    
712
 
713
    
714
      
715
        
716
#include <cyg/ppp/ppp.h>
717
        
718
        
719
          cyg_int32 cyg_ppp_down
720
          cyg_ppp_handle_t handle
721
        
722
      
723
    
724
 
725
    Description
726
727
This function brings the PPP connection down. The
728
handle argument is the result of a successful
729
call to cyg_ppp_up(). This function only signals
730
to the PPP subsystem that the link should be brought down. The link
731
will be terminated asynchronously. If the application needs to wait
732
for the link to terminate, then it should call
733
cyg_ppp_wait_down() after calling
734
cyg_ppp_down().
735
736
 
737
738
The function returns zero if it was able to start the termination of
739
the PPP connection successfully. It will return -1 if the connection
740
is not running, or if it could not otherwise start the termination.
741
742
 
743
    
744
 
745
746
 
747
748
749
 
750
751
 
752
    
753
    cyg_ppp_wait_up()
754
    
755
 
756
    
757
      cyg_ppp_wait_up
758
      Wait for PPP connection to come up
759
    
760
 
761
    
762
      
763
        
764
#include <cyg/ppp/ppp.h>
765
        
766
        
767
          cyg_int32 cyg_ppp_wait_up
768
          cyg_ppp_handle_t handle
769
        
770
      
771
    
772
 
773
    Description
774
775
This function waits until the PPP connection is running and then
776
returns. This is needed because the actual bring up of the connection
777
happens mostly after the call to cyg_ppp_up()
778
returns, and may take some time to complete, especially if dialling a
779
remote server.
780
781
 
782
783
The result of this call will be zero when the connection is running,
784
or -1 if the connection failed to start for some reason. If the
785
connection is already running when this call is made it will return
786
immediately with a zero result. If the connection is not in the
787
process of coming up, or has failed, or has terminated, then a result
788
of -1 will be returned immediately. Thus this function may also be
789
used to test that the connection is still running at any point.
790
791
 
792
    
793
 
794
795
 
796
797
798
 
799
800
 
801
    
802
    cyg_ppp_wait_down()
803
    
804
 
805
    
806
      cyg_ppp_wait_down
807
      Wait for PPP connection to terminate
808
    
809
 
810
    
811
      
812
        
813
#include <cyg/ppp/ppp.h>
814
        
815
        
816
          void cyg_ppp_wait_down
817
          cyg_ppp_handle_t handle
818
        
819
      
820
    
821
 
822
    Description
823
824
This function waits for the PPP connection to terminate. The link may
825
be terminated with a call to cyg_ppp_down(), by
826
the remote end, or by the telephone line being dropped or lost.
827
828
 
829
830
This function has no return value. If the PPP connection is not
831
running, or has terminated, it will return. Applications should use
832
cyg_ppp_wait_up() to test the link state.
833
834
 
835
    
836
 
837
838
 
839
840
841
 
842
843
 
844
    
845
    cyg_ppp_chat()
846
    
847
 
848
    
849
      cyg_ppp_chat
850
      Execute chat script
851
    
852
 
853
    
854
      
855
        
856
#include <cyg/ppp/ppp.h>
857
        
858
        
859
          cyg_int32 cyg_ppp_chat
860
          const char *devname
861
          const char *script[]
862
        
863
      
864
    
865
 
866
    Description
867
868
This function implements a subset of the automated conversational
869
scripting as defined by the chat program. The first
870
argument is the name of the serial device to be used, typically
871
"/dev/ser0" or "/dev/ser1". The
872
script argument is a pointer to a zero
873
terminated array of strings that comprise the chat script. See 
874
linkend="ppp-using"> for an example script, and 
875
linkend="ppp-chat"> for full detail of the script used.
876
877
 
878
879
The return value of this function will be zero if the chat script
880
fails for any reason, such as an ABORT or a timeout. If the end of the
881
script is reached, then the return value will be non-zero.
882
883
 
884
885
Under normal use this function is called from the PPP subsystem if the
886
cyg_ppp_options_t
887
script field is set to a
888
non-NULL value. This function should only be used
889
directly if the application needs to undertake special processing
890
between running the chat script, and bringing up the PPP connections.
891
892
 
893
    
894
 
895
896
 
897
898
 
899
 
900
901
 
902
903
 
904
905
906
 
907
908
Installing and Configuring PPP
909
 
910
911
Including PPP in a Configuration
912
 
913
914
PPP is contained entirely within a single
915
eCos package. So to include PPP in a
916
configuration all you need to do is add that package.
917
918
 
919
920
In the GUI configuration tool use the
921
Build->Packages menu item, find the "PPP Support"
922
package in the left-hand pane and use the Add button
923
to add it to the list of packages in use in the right-hand pane.
924
925
 
926
927
In the command-line tool ecosconfig, you can use the
928
following command during the configuration phase to add the PPP package:
929
930
 
931
932
 
933
$ ecosconfig add ppp
934
 
935
936
 
937
938
In addition to the PPP package you will also need to have the
939
"Network" package and the "Serial Device
940
Drivers" package in the configuration. The dependencies and
941
requirements of the networking package are such that it is strongly
942
recommended that you start with the net template.
943
944
 
945
946
See the eCos User Guide for full details on
947
how to configure and build eCos.
948
949
 
950
951
 
952
 
953
954
Configuring PPP
955
956
The PPP package contains a number of configuration options that may be
957
changed to affect its behaviour.
958
 
959
960
 
961
962
  CYGNUM_PPP_PPPD_THREAD_PRIORITY
963
  
964
    
965
    The PPP system contains two threads, One is used for receiving
966
    data from the link and processing control packets.  The other is
967
    used to transmit data asynchronously to the link when it cannot be
968
    completed synchronously. The receive thread runs at the priority
969
    given here, and the transmit thread runs at the next lower
970
    priority.  The exact priority needed here depends on the
971
    importance of the PPP subsystem relative to the rest of the
972
    system. The default is to put it in the middle of the priority
973
    range to provide reasonable response without impacting genuine
974
    high priority threads.
975
    
976
    
977
    Default value: CYGNUM_KERNEL_SCHED_PRIORITIES/2
978
    
979
  
980
981
 
982
983
  CYGPKG_PPP_DEBUG_WARN_ONLY
984
  
985
    
986
    The runtime debug option enables logging of
987
    high level debug messages. Too many of these can interfere with
988
    the PPP device and may result in missed messages.  This is because
989
    these messages are emitted via the diag_printf() mechanism, which
990
    disables interrupts while it prints.  By default, therefore, we
991
    only report errors and warnings, and not all events. Setting this
992
    option to zero will enable the logging of all events.
993
    
994
    
995
    Default value: 1
996
    
997
  
998
999
 
1000
1001
  CYGPKG_PPP_AUTH_DEFAULT_USER
1002
  
1003
    
1004
    This option gives the default value for the user name used to
1005
    initialize the user field in the PPP
1006
    options.
1007
    
1008
    
1009
    Default value: "eCos"
1010
    
1011
  
1012
1013
 
1014
1015
  CYGPKG_PPP_AUTH_DEFAULT_PASSWD
1016
  
1017
    
1018
    This option gives the default value for the password used to
1019
    initialize the passwd field in the PPP
1020
    options.
1021
    
1022
    
1023
    Default value: "secret"
1024
    
1025
  
1026
1027
 
1028
1029
  CYGPKG_PPP_DEFAULT_DIALUP_NUMBER
1030
  
1031
    
1032
    This option provides a default dialup number for use in
1033
    chat scripts. This value is not used anywhere
1034
    in the PPP package, but is provided to complete the information
1035
    needed, alongside the user name and password, for accessing a
1036
    typical dialup server.
1037
    
1038
    
1039
    Default value: "5551234"
1040
    
1041
  
1042
1043
 
1044
1045
  CYGPKG_PPP_PAP
1046
  
1047
    
1048
    This component enables the inclusion of PAP authentication
1049
    support.
1050
    
1051
    
1052
    Default value: 1
1053
    
1054
  
1055
1056
 
1057
1058
  CYGPKG_PPP_CHAP
1059
  
1060
    
1061
    This component enables the inclusion of CHAT authentication
1062
    support.
1063
    
1064
    
1065
    Default value: 1
1066
    
1067
  
1068
1069
 
1070
1071
  CYGPKG_PPP_COMPRESSION
1072
  
1073
    
1074
    This component provides control over PPP compression
1075
    features. WARNING: at present there are problems with this option,
1076
    and and in any case the compression code needs to allocate large
1077
    amounts of memory. Hence this option is currently disabled and
1078
    should remain so.
1079
    
1080
    
1081
    Default value: 0
1082
    
1083
  
1084
1085
 
1086
1087
  PPP_BSDCOMP
1088
  
1089
    
1090
    This option enables inclusion of BSD compression into the PPP
1091
    protocol.
1092
    
1093
    
1094
    Default value: 0
1095
    
1096
  
1097
1098
 
1099
1100
  PPP_DEFLATE
1101
  
1102
    
1103
    This option enables inclusion of ZLIB compression into the PPP
1104
    protocol.
1105
    
1106
    
1107
    Default value: 0
1108
    
1109
  
1110
1111
 
1112
1113
  CYGPKG_PPP_CHAT
1114
  
1115
    
1116
    This component enables the inclusion of a simple scripting system
1117
    to bring up PPP connections.  It implements a subset of the
1118
    chat scripting language.
1119
    
1120
    
1121
    Default value: 1
1122
    
1123
  
1124
1125
 
1126
1127
  CYGNUM_PPP_CHAT_ABORTS_MAX
1128
  
1129
    
1130
    This option defines the maximum number of ABORT
1131
    strings that the CHAT system will store.
1132
    
1133
    
1134
    Default value: 10
1135
    
1136
  
1137
1138
 
1139
1140
  CYGNUM_PPP_CHAT_ABORTS_SIZE
1141
  
1142
    
1143
    This option defines the maximum size of each
1144
    ABORT strings that the chat
1145
    system will store.
1146
    
1147
    
1148
    Default value: 20
1149
    
1150
  
1151
1152
 
1153
1154
  CYGNUM_PPP_CHAT_STRING_LENGTH
1155
  
1156
    
1157
    This option defines the maximum size of any expect or reply
1158
    strings that the chat system will be given.
1159
    
1160
    
1161
    Default value: 256
1162
    
1163
  
1164
1165
 
1166
1167
  CYGPKG_PPP_TEST_DEVICE
1168
  
1169
    
1170
    This option defines the serial device to be used for PPP test
1171
    programs.
1172
    
1173
    
1174
    Default value: "/dev/ser0"
1175
    
1176
  
1177
1178
 
1179
1180
  CYGPKG_PPP_TESTS_AUTOMATE
1181
  
1182
    
1183
    This option enables automated testing features in certain test
1184
    programs. These programs will interact with a test server at the
1185
    remote end of the serial link to run a variety of tests in
1186
    different conditions. Without this option most tests default to
1187
    running a single test instance and are suitable for being run by
1188
    hand for debugging purposes.
1189
    
1190
    
1191
    Default value: 0
1192
    
1193
  
1194
1195
 
1196
1197
  CYGDAT_PPP_TEST_BAUD_RATES
1198
  
1199
    
1200
    This option supplies a list of baud rates at which certain tests
1201
    will run if the CYGPKG_PPP_TESTS_AUTOMATE
1202
    option is set.
1203
    
1204
    
1205
    Default value: "CYGNUM_SERIAL_BAUD_19200,CYGNUM_SERIAL_BAUD_38400,CYGNUM_SERIAL_BAUD_57600,CYGNUM_SERIAL_BAUD_115200"
1206
    
1207
  
1208
1209
 
1210
1211
 
1212
 
1213
1214
 
1215
1216
 
1217
 
1218
1219
 
1220
1221
1222
 
1223
1224
CHAT Scripts
1225
1226
The automated conversational scripting supported by the
1227
eCos PPP package is a subset of the
1228
scripting language provided by the chat command
1229
found on most UNIX and Linux systems.
1230
1231
 
1232
1233
Unlike the chat command, the
1234
eCos cyg_ppp_chat()
1235
function takes as a parameter a zero-terminated array of pointers to
1236
strings. In most programs this will be defined by means of an
1237
initializer for a static array, although there is nothing to stop the
1238
application constructing it at runtime. A simple script would be
1239
defined like this:
1240
1241
 
1242
1243
 
1244
static char *chat_script[] =
1245
{
1246
    "ABORT"        ,  "BUSY"        ,
1247
    "ABORT"        ,  "NO CARRIER"  ,
1248
    ""             ,  "ATD5551234"  ,
1249
    "ogin:--ogin:" ,  "ppp"         ,
1250
    "ssword:"      ,  "hithere"     ,
1251
 
1252
};
1253
 
1254
1255
 
1256
1257
The following sections have been abstracted from the public domain
1258
documentation for the chat command.
1259
1260
 
1261
 
1262
1263
Chat Script
1264
1265
       A script consists of one or more "expect-send" pairs of
1266
       strings, separated by spaces, with an optional "subexpect-
1267
       subsend" string pair, separated by a dash as in the following
1268
       example:
1269
1270
 
1271
1272
 
1273
    "ogin:--ogin:"     ,  "ppp"       ,
1274
    "ssword:"          ,   "hello2u2" ,
1275
 
1276
 
1277
1278
 
1279
1280
       This script fragment indicates that the
1281
       cyg_ppp_chat() function should expect the
1282
       string "ogin:". If it fails to receive a login prompt within
1283
       the time interval allotted, it is to send a carriage return
1284
       to the remote and then expect the string "ogin:" again.  If
1285
       the first "ogin:" is received then the carriage return is not
1286
       generated.
1287
1288
1289
       Once it received the login prompt the
1290
       cyg_ppp_chat() function will send the
1291
       string "ppp" and then expect the prompt "ssword:".  When it
1292
       receives the prompt for the password, it will send the password
1293
       "hello2u2".
1294
1295
1296
       A carriage return is normally sent following the reply string.
1297
       It is not expected in the "expect" string unless it is
1298
       specifically requested by using the "\r" character sequence.
1299
1300
1301
       The expect sequence should contain only what is needed to
1302
       identify the string. It should not contain variable
1303
       information. It is generally not acceptable to look for time
1304
       strings, network identification strings, or other variable
1305
       pieces of data as an expect string.
1306
1307
1308
       To help correct for characters which may be corrupted during
1309
       the initial sequence, look for the string "ogin:" rather than
1310
       "login:". It is possible that the leading "l" character may be
1311
       received in error and you may never find the string even though
1312
       it was sent by the system. For this reason, scripts look for
1313
       "ogin:" rather than "login:" and "ssword:" rather than
1314
       "password:".
1315
1316
1317
       A very simple script might look like this:
1318
1319
1320
 
1321
    "ogin:"    , "ppp"       ,
1322
    "ssword:"  , " hello2u2" ,
1323
 
1324
 
1325
1326
 
1327
1328
       In other words, expect "....ogin:", send "ppp", expect "...ssword:",
1329
       send "hello2u2".
1330
1331
1332
       In actual practice, simple scripts are rare. At the very least,
1333
       you should include sub-expect sequences should the original
1334
       string not be received. For example, consider the following
1335
       script:
1336
1337
1338
 
1339
    "ogin:--ogin:"  , "ppp"     ,
1340
    "ssword:"       , "hello2u2",
1341
 
1342
 
1343
1344
1345
       This would be a better script than the simple one used earlier.
1346
       This would look for the same "login:" prompt, however, if one
1347
       was not received, a single return sequence is sent and then it
1348
       will look for "login:" again. Should line noise obscure the
1349
       first login prompt then sending the empty line will usually
1350
       generate a login prompt again.
1351
1352
 
1353
1354
 
1355
1356
ABORT Strings
1357
 
1358
1359
       Many modems will report the status of the call as a
1360
       string. These strings may be CONNECTED or NO CARRIER or
1361
       BUSY. It is often desirable to terminate the script should the
1362
       modem fail to connect to the remote. The difficulty is that a
1363
       script would not know exactly which modem string it may
1364
       receive. On one attempt, it may receive BUSY while the next
1365
       time it may receive NO CARRIER.
1366
1367
1368
       These "abort" strings may be specified in the script using
1369
       the ABORT sequence. It is written in the script as in  the
1370
       following example:
1371
1372
1373
 
1374
    "ABORT"    , "BUSY"    ,
1375
    "ABORT"    , "NO CARRIER"  ,
1376
    ""         , "ATZ"         ,
1377
    "OK"       , "ATDT5551212" ,
1378
    "CONNECT"  , ...
1379
 
1380
1381
 
1382
1383
       This sequence will expect nothing; and then send the string
1384
       ATZ.  The expected response to this is the string OK. When it
1385
       receives OK, it sends the string ATDT5551212 to dial the
1386
       telephone.  The expected string is CONNECT. If the string
1387
       CONNECT is received the remainder of the script is
1388
       executed. However, should the modem find a busy telephone, it
1389
       will send the string BUSY. This will cause the string to match
1390
       the abort character sequence. The script will then fail because
1391
       it found a match to the abort string. If it received the string
1392
       NO CARRIER, it will abort for the same reason. Either string
1393
       may be received. Either string will terminate the chat script.
1394
1395
 
1396
1397
 
1398
1399
TIMEOUT
1400
1401
       The initial timeout value  is  45  seconds.
1402
       To  change  the  timeout value for the next expect string,
1403
       the following example may be used:
1404
1405
1406
 
1407
    ""              , "ATZ"         ,
1408
    "OK"            , "ATDT5551212" ,
1409
    "CONNECT"       , "\\c"         ,
1410
    "TIMEOUT"       , "10"          ,
1411
    "ogin:--ogin:"  , "ppp"         ,
1412
    "TIMEOUT"       , "5"           ,
1413
    "assword:"      , "hello2u2"    ,
1414
 
1415
 
1416
1417
1418
       This will change the timeout to 10 seconds when it expects the
1419
       login: prompt. The timeout is then changed to 5 seconds when
1420
       it looks for the password prompt.
1421
1422
1423
       The  timeout,  once changed, remains in effect until it is
1424
       changed again.
1425
1426
 
1427
1428
 
1429
1430
Sending EOT
1431
1432
       The special reply string of EOT indicates  that  the  chat
1433
       program  should  send an EOT character to the remote. This
1434
       is normally the End-of-file character sequence.  A  return
1435
       character is not sent following the EOT.  The EOT sequence
1436
       may be embedded into the send string  using  the  sequence
1437
       "\x04" (i.e. a Control-D character).
1438
1439
1440
 
1441
1442
Escape Sequences
1443
1444
Most standard chat escape sequences can be replaced
1445
with standard C string escapes such as '\r', '\n', '\t'
1446
etc. Additional escape sequences may be embedded in the expect or
1447
reply strings by introducing them with two
1448
backslashes.
1449
1450
 
1451
1452
 
1453
1454
\\c
1455
1456
1457
Suppresses the newline at the end of the reply string.  This is the
1458
only method to send a string without a trailing return character. It
1459
must be at the end of the send string.  For example, the sequence
1460
"hello\\c" will simply send the characters h, e, l, l, o.  (not valid
1461
in expect strings.)
1462
1463
1464
1465
 
1466
1467
 
1468
1469
 
1470
1471
 
1472
1473
1474
 
1475
1476
PPP Enabled Device Drivers
1477
1478
For PPP to function fully over a serial device, its driver must
1479
implement certain features. At present not all
1480
eCos serial drivers implement these
1481
features. A driver indicates that it supports a certain feature by
1482
including an "implements" line in its CDL for the
1483
following interfaces:
1484
1485
 
1486
1487
 
1488
1489
CYGINT_IO_SERIAL_FLOW_CONTROL_HW
1490
1491
1492
This interface indicates that the driver implements hardware flow
1493
control using the RTS and CTS lines. When data is being transferred
1494
over high speed data lines, it is essential that flow control be used
1495
to prevent buffer overrun.
1496
1497
1498
The PPP subsystem functions best with hardware flow control. If this
1499
is not available, then it can be configured to use software flow
1500
control. Since software flow control is implemented by the device
1501
independent part of the serial device infrastructure, it is available
1502
for all serial devices. However, this will have an effect on the
1503
performance and reliability of the PPP link.
1504
1505
1506
1507
 
1508
 
1509
1510
CYGINT_IO_SERIAL_LINE_STATUS_HW
1511
1512
1513
This interface indicates that the driver implements a callback
1514
interface for indicating the status of various RS232 control lines. Of
1515
particular interest here is the ability to detect changes in the
1516
Carrier Detect (CD) line. Not all drivers that implement this
1517
interface can indicate CD status.
1518
1519
1520
This functionality is only needed if it is important that the link be
1521
dropped immediately a telephone connection fails. Without it, a
1522
connection will only be dropped after it times out. This may be
1523
acceptable in many situations.
1524
1525
1526
1527
 
1528
1529
 
1530
1531
At the time of writing, the serial device drivers for the following
1532
platforms implement some or all of the required functionality:
1533
1534
 
1535
1536
 
1537
1538
1539
All drivers that use the generic 16x5x driver implement all functions:
1540
1541
1542
ARM CerfPDA
1543
ARM IQ80321
1544
ARM PID
1545
ARM IOP310
1546
i386 PC
1547
MIPS Atlas
1548
MIPS Ref4955
1549
SH3 SE77x9
1550
1551
1552
 
1553
1554
1555
The following drivers implement flow control but either do not support
1556
line status callbacks, or do not report CD changes:
1557
1558
1559
SH4 SCIF
1560
A&M AdderI
1561
A&M AdderII
1562
1563
1564
 
1565
1566
1567
All other drivers can support software flow control only.
1568
1569
1570
 
1571
1572
 
1573
 
1574
1575
 
1576
1577
1578
 
1579
1580
Testing
1581
 
1582
 
1583
1584
Test Programs
1585
 
1586
1587
There are a number of test programs supplied with the PPP
1588
subsystem. By default all of these tests use the device configured by
1589
CYGPKG_PPP_TEST_DEVICE as the PPP link device.
1590
1591
 
1592
1593
 
1594
1595
ppp_up
1596
1597
1598
This test just brings up the PPP link on
1599
CYGPKG_PPP_TEST_DEVICE and waits until the remote end brings
1600
it back down. No modem lines are used and the program expects a PPP
1601
connection to be waiting on the other end of the line. Typically the
1602
remote end will test the link using ping or access
1603
the HTTP system monitor if it is present.
1604
1605
1606
If CYGPKG_PPP_TESTS_AUTOMATE is set, then this test
1607
attempts to bring PPP up at each of the baud rates specified in
1608
CYGDAT_PPP_TEST_BAUD_RATES. If it is not set then
1609
it will just bring the connection up at 115200 baud.
1610
1611
1612
1613
 
1614
1615
ppp_updown
1616
1617
1618
This test brings the PPP link up on
1619
CYGPKG_PPP_TEST_DEVICE and attempts to
1620
ping the remote end of the link. Once the pings
1621
have finished, the link is then brought down.
1622
1623
1624
If CYGPKG_PPP_TESTS_AUTOMATE is set, then this test
1625
attempts to bring PPP up at each of the baud rates specified in
1626
CYGDAT_PPP_TEST_BAUD_RATES. If it is not set then
1627
it will just bring the connection up at 115200 baud.
1628
1629
1630
1631
 
1632
1633
chat
1634
1635
1636
This test does not bring the PPP link up but simply executes a chat
1637
script. It expects a server at the remote end of the link to supply
1638
the correct responses.
1639
1640
1641
This program expects the test_server.sh script to
1642
be running on the remote end and attempts several different tests,
1643
expecting a variety of different responses for each.
1644
1645
1646
1647
 
1648
1649
ppp_auth
1650
1651
1652
This test attempts to bring up the PPP link under a variety of
1653
different authentication conditions. This includes checking that both
1654
PAP and CHAP authentication work, and that the connection is rejected
1655
when the incorrect authentication protcol or secrets are used.
1656
1657
1658
This test expects the test_server.sh script to be
1659
running on the remote end. For this test to work the /etc/ppp/pap-secrets file on the remote
1660
end should contain the following two lines:
1661
1662
1663
eCos       *         secret       *
1664
eCosPAP    *         secretPAP    *
1665
1666
1667
The /etc/ppp/chap-secrets file should contain:
1668
1669
1670
eCos       *         secret       *
1671
eCosCHAP   *         secretCHAP   *
1672
1673
1674
1675
 
1676
1677
isp
1678
1679
1680
This test expects the serial test device to be connected to a Hayes
1681
compatible modem. The test dials the telephone number given in
1682
CYGPKG_PPP_DEFAULT_DIALUP_NUMBER and attempts to
1683
log on to an ISP using the user name and password supplied in
1684
CYGPKG_PPP_AUTH_DEFAULT_USER and
1685
CYGPKG_PPP_AUTH_DEFAULT_PASSWD. Once the PPP
1686
connection has been made, the program then attempts to ping a number
1687
of well known addresses.
1688
1689
1690
Since this test is designed to interact with an ISP, it does not run
1691
within the automated testing system.
1692
1693
1694
1695
 
1696
1697
tcp_echo
1698
1699
1700
This is a version of the standard network tcp_echo
1701
test that brings up the PPP connection before waiting for the
1702
tcp_sink and tcp_source programs
1703
to connect. It is expected that at least one of these programs will
1704
connect via the PPP link. However, if another network interface is
1705
present, such as an ethernet device, then one may connect via that
1706
interface.
1707
1708
1709
While this test is supported by the test_server.sh
1710
script, it runs for such a long time that it should not normally be
1711
used during automated testing.
1712
1713
1714
1715
 
1716
1717
nc_test_slave
1718
1719
1720
This is a version of the standard network
1721
nc_test_slave test that brings up the PPP
1722
connection before waiting for the nc_test_master
1723
program to connect. It is expected that the master will connect via
1724
the PPP link.
1725
1726
1727
While this test is supported by the test_server.sh
1728
script, it runs for such a long time that it should not normally be
1729
used during automated testing.
1730
1731
1732
1733
 
1734
1735
 
1736
1737
 
1738
1739
Test Script
1740
 
1741
1742
The PPP package additionally contains a shell script
1743
(test_server.sh) that may be used to operate the
1744
remote end of a PPP test link.
1745
1746
 
1747
1748
The script may be invoked with the following arguments:
1749
1750
 
1751
1752
 
1753
1754
--dev=<devname>
1755
1756
1757
This mandatory option gives the name of the device to be used for the
1758
PPP link. Typically "/dev/ttyS0" or
1759
"/dev/ttyS1".
1760
1761
1762
1763
 
1764
1765
--myip=<ipaddress>
1766
1767
1768
This mandatory option gives the IP address to be attached to this end
1769
of the PPP link.
1770
1771
1772
1773
 
1774
1775
--hisip=<ipaddress>
1776
1777
1778
This mandatory option gives the IP address to be attached to the
1779
remote (test target) end of the PPP link.
1780
1781
1782
1783
 
1784
1785
--baud=<baud_rate>
1786
1787
1788
This option gives the baud rate at which the PPP link is to be run. If
1789
absent then the link will run at the value set for
1790
--redboot-baud.
1791
1792
1793
1794
 
1795
1796
--redboot
1797
1798
1799
If this option is present then the script will look for a
1800
"RedBoot>" prompt between test runs. This is
1801
necessary if the serial device being used for testing is also used by
1802
RedBoot.
1803
1804
1805
1806
 
1807
1808
--redboot-baud=<baud_rate>
1809
1810
1811
This option gives the baud rate at which the search for the RedBoot
1812
prompt will be made. If absent then the link will run at 38400 baud.
1813
1814
1815
1816
 
1817
1818
--debug
1819
1820
1821
If this option is present, then the script will print out some
1822
additional debug messages while it runs.
1823
1824
1825
1826
 
1827
1828
 
1829
1830
This script operates as follows: If the --redboot
1831
option is set it sets the device baud rate to the RedBoot baud rate
1832
and waits until a "RedBoot>" prompt is encountered.
1833
It then sets the baud rate to the value given by the
1834
--baud option and reads lines from the device until
1835
a recognizable test announce string is read. It then executes an
1836
appropriate set of commands to satisfy the test. This usually means
1837
bringing up the PPP link by running pppd and maybe
1838
executing various commands. It then either terminates the link itself,
1839
or waits for the target to terminate it. It then goes back to looking
1840
for another test announce string. If a string of the form
1841
"BAUD:XXX" is received then the baud rate is
1842
changed depending on the XXX value. If a
1843
"FINISH" string is received it returns to waiting
1844
for a "RedBoot>" prompt. The script repeats this
1845
process until it is terminated with a signal.
1846
1847
 
1848
1849
 
1850
1851
 
1852
1853
 
1854
 
1855

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.