Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:24:35

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /*
0004  *  COPYRIGHT (c) 1989-2012.
0005  *  On-Line Applications Research Corporation (OAR).
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  *
0016  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0017  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0018  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0019  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0020  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0021  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0022  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0023  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0024  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0025  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0026  * POSSIBILITY OF SUCH DAMAGE.
0027  */
0028 
0029 #ifdef HAVE_CONFIG_H
0030 #include "config.h"
0031 #endif
0032 
0033 #include <tmacros.h>
0034 #include <termios.h>
0035 #include <rtems/termiostypes.h>
0036 #include <rtems/dumpbuf.h>
0037 
0038 /* forward declarations to avoid warnings */
0039 void ppp_test_driver_set_rx(const char *expected, size_t len);
0040 void pppasyncattach(void);
0041 int  pppopen(struct rtems_termios_tty *tty);
0042 int  pppclose(struct rtems_termios_tty *tty);
0043 int  pppread(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args);
0044 int  pppwrite(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args);
0045 int  pppioctl(struct rtems_termios_tty *tty, rtems_libio_ioctl_args_t *args);
0046 int  pppinput(int c, struct rtems_termios_tty *tty);
0047 int  pppstart(struct rtems_termios_tty *tp, int len);
0048 
0049 /*
0050  * Define the PPP line discipline.
0051  */
0052 
0053 static struct rtems_termios_linesw pppdisc = {
0054   pppopen, pppclose, pppread, pppwrite,
0055   pppinput, pppstart, pppioctl, NULL
0056 };
0057 
0058 const char *RXExpected;
0059 size_t      RXLength;
0060 
0061 void ppp_test_driver_set_rx( const char *expected, size_t len )
0062 {
0063   RXExpected = expected;
0064   RXLength   = len;
0065 }
0066 
0067 void pppasyncattach(void)
0068 {
0069   rtems_termios_linesw[PPPDISC] = pppdisc;
0070 }
0071 
0072 int  pppopen(struct rtems_termios_tty *tty)
0073 {
0074   puts( "pppopen called" );
0075   return 0;
0076 }
0077 
0078 int  pppclose(struct rtems_termios_tty *tty)
0079 {
0080   puts( "pppclose called" );
0081   return 0;
0082 }
0083 
0084 int  pppread(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args)
0085 {
0086   puts( "pppread called" );
0087   
0088   rtems_termios_enqueue_raw_characters( tty, (char *)RXExpected, RXLength );
0089   
0090   RXExpected = NULL;
0091   RXLength = 0;
0092   return 0;
0093 }
0094 
0095 int  pppwrite(struct rtems_termios_tty *tty, rtems_libio_rw_args_t *rw_args)
0096 {
0097   int                           maximum    = rw_args->count;
0098   char                         *out_buffer = rw_args->buffer; 
0099 
0100   printf( "pppwrite called - %d bytes\n", maximum );
0101   rtems_print_buffer( (unsigned char *) out_buffer, maximum );
0102   rw_args->bytes_moved = maximum;
0103   rtems_termios_dequeue_characters( tty, 1 );
0104   return 0;
0105 }
0106 
0107 int  pppioctl(struct rtems_termios_tty *tty, rtems_libio_ioctl_args_t *args)
0108 {
0109   puts( "pppioctl called" );
0110   return 0;
0111 }
0112 
0113 int  pppinput(int c, struct rtems_termios_tty *tty)
0114 {
0115   printf( "pppinput called - with (%c)\n", c );
0116   return 0;
0117 }
0118 
0119 int  pppstart(struct rtems_termios_tty *tp, int len)
0120 {
0121   puts( "pppstart called" );
0122   return 0;
0123 }
0124 
0125