1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2012. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | */ |
---|
9 | |
---|
10 | #ifdef HAVE_CONFIG_H |
---|
11 | #include "config.h" |
---|
12 | #endif |
---|
13 | |
---|
14 | #include <tmacros.h> |
---|
15 | #include <termios.h> |
---|
16 | #include <rtems/termiostypes.h> |
---|
17 | #include <rtems/dumpbuf.h> |
---|
18 | |
---|
19 | /* forward declarations to avoid warnings */ |
---|
20 | void ppp_test_driver_set_rx(const char *expected, size_t len); |
---|
21 | void pppasyncattach(void); |
---|
22 | int pppopen(struct rtems_termios_tty *tty); |
---|
23 | int pppclose(struct rtems_termios_tty *tty); |
---|
24 | int pppread(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args); |
---|
25 | int pppwrite(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args); |
---|
26 | int pppioctl(struct rtems_termios_tty *tty, rtems_libio_ioctl_args_t *args); |
---|
27 | int pppinput(int c, struct rtems_termios_tty *tty); |
---|
28 | int pppstart(struct rtems_termios_tty *tp); |
---|
29 | |
---|
30 | /* |
---|
31 | * Define the PPP line discipline. |
---|
32 | */ |
---|
33 | |
---|
34 | static struct rtems_termios_linesw pppdisc = { |
---|
35 | pppopen, pppclose, pppread, pppwrite, |
---|
36 | pppinput, pppstart, pppioctl, NULL |
---|
37 | }; |
---|
38 | |
---|
39 | const char *RXExpected; |
---|
40 | size_t RXLength; |
---|
41 | |
---|
42 | void ppp_test_driver_set_rx( const char *expected, size_t len ) |
---|
43 | { |
---|
44 | RXExpected = expected; |
---|
45 | RXLength = len; |
---|
46 | } |
---|
47 | |
---|
48 | void pppasyncattach(void) |
---|
49 | { |
---|
50 | rtems_termios_linesw[PPPDISC] = pppdisc; |
---|
51 | } |
---|
52 | |
---|
53 | int pppopen(struct rtems_termios_tty *tty) |
---|
54 | { |
---|
55 | puts( "pppopen called" ); |
---|
56 | return 0; |
---|
57 | } |
---|
58 | |
---|
59 | int pppclose(struct rtems_termios_tty *tty) |
---|
60 | { |
---|
61 | puts( "pppclose called" ); |
---|
62 | return 0; |
---|
63 | } |
---|
64 | |
---|
65 | int pppread(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args) |
---|
66 | { |
---|
67 | puts( "pppread called" ); |
---|
68 | |
---|
69 | rtems_termios_enqueue_raw_characters( tty, (char *)RXExpected, RXLength ); |
---|
70 | |
---|
71 | RXExpected = NULL; |
---|
72 | RXLength = 0; |
---|
73 | return 0; |
---|
74 | } |
---|
75 | |
---|
76 | int pppwrite(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args) |
---|
77 | { |
---|
78 | int maximum = rw_args->count; |
---|
79 | char *out_buffer = rw_args->buffer; |
---|
80 | |
---|
81 | printf( "pppwrite called - %d bytes\n", maximum ); |
---|
82 | rtems_print_buffer( (unsigned char *) out_buffer, maximum ); |
---|
83 | rw_args->bytes_moved = maximum; |
---|
84 | rtems_termios_dequeue_characters( tty, 1 ); |
---|
85 | return 0; |
---|
86 | } |
---|
87 | |
---|
88 | int pppioctl(struct rtems_termios_tty *tty, rtems_libio_ioctl_args_t *args) |
---|
89 | { |
---|
90 | puts( "pppioctl called" ); |
---|
91 | return 0; |
---|
92 | } |
---|
93 | |
---|
94 | int pppinput(int c, struct rtems_termios_tty *tty) |
---|
95 | { |
---|
96 | printf( "pppinput called - with (%c)\n", c ); |
---|
97 | return 0; |
---|
98 | } |
---|
99 | |
---|
100 | int pppstart(struct rtems_termios_tty *tp) |
---|
101 | { |
---|
102 | puts( "pppstart called" ); |
---|
103 | return 0; |
---|
104 | } |
---|
105 | |
---|
106 | |
---|