1 /*
2  *  ser2net - A program for allowing telnet connection to serial ports
3  *  Copyright (C) 2001  Corey Minyard <minyard@acm.org>
4  *
5  *  This program is free software; you can redistribute it and/or modify
6  *  it under the terms of the GNU General Public License as published by
7  *  the Free Software Foundation; either version 2 of the License, or
8  *  (at your option) any later version.
9  *
10  *  This program is distributed in the hope that it will be useful,
11  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *  GNU General Public License for more details.
14  *
15  *  You should have received a copy of the GNU General Public License
16  *  along with this program; if not, write to the Free Software
17  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18  */
19 
20 #ifndef DATAXFER
21 #define DATAXFER
22 
23 #include "utils.h"
24 #include "controller.h"
25 
26 #ifdef USE_UUCP_LOCKING
27 extern int uucp_locking_enabled;
28 #endif
29 
30 #ifdef linux
31 
32 #include <sys/serial.h>
33 
34 /* Check, if the toolchain provides SER_RS485_RX_DURING_TX macro
35  * (introduced in kernel 3.2) */
36 #if HAVE_DECL_TIOCSRS485
37 #ifndef SER_RS485_RX_DURING_TX
38 #define SER_RS485_RX_DURING_TX          (1 << 4)
39 #endif /* SER_RS485_RX_DURING_TX */
40 #endif /* HAVE_DECL_TIOCSRS485 */
41 
42 #endif /* linux */
43 
44 /* Create a port given the criteria. */
45 int portconfig(struct absout *eout,
46 	       char *portnum,
47 	       char *state,
48 	       char *timeout,
49 	       char *devname,
50 	       char *devcfg,
51 	       int  config_num);
52 
53 /* Shut down all the ports, and provide a way to check when done. */
54 void shutdown_ports(void);
55 int check_ports_shutdown(void);
56 
57 /* Clear out any old ports on a reconfigure. */
58 void clear_old_port_config(int config_num);
59 
60 /* Initialize the data transfer code. */
61 void dataxfer_init(void);
62 
63 /* Show information about a port (or all ports if portspec is NULL).
64    The parameters are all strings that the routine will convert to
65    integers.  Error output will be generated on invalid data. */
66 void showports(struct controller_info *cntlr, char *portspec);
67 
68 /* Show information about a port (as above) but in a one-line format. */
69 void showshortports(struct controller_info *cntlr, char *portspec);
70 
71 /* Set the port's timeout.  The parameters are all strings that the
72    routine will convert to integers.  Error output will be generated
73    on invalid data. */
74 void setporttimeout(struct controller_info *cntlr,
75 		    char *portspec,
76 		    char *timeout);
77 
78 /* Set the serial port's configuration.  The parameters are all
79    strings that the routine will convert to integers.  Error output
80    will be generated on invalid data. */
81 void setportdevcfg(struct controller_info *cntlr,
82 		   char *portspec,
83 		   char *devcfg);
84 
85 /* Modify the DTR and RTS lines for the port. */
86 void setportcontrol(struct controller_info *cntlr,
87 		    char *portspec,
88 		    char *controls);
89 
90 /* Set the enable state of a port (off, raw, telnet).  The parameters
91    are all strings that the routine will convert to integers.  Error
92    output will be generated on invalid data. */
93 void setportenable(struct controller_info *cntlr,
94 		   char *portspec,
95 		   char *enable);
96 
97 /* Start data monitoring on the given port, type may be either "tcp" or
98    "term" and only one direction may be monitored.  This return NULL if
99    the monitor fails.  The monitor output will go to the controller
100    via the controller_write() call. */
101 void *data_monitor_start(struct controller_info *cntlr,
102 			 char *type,
103 			 char *portspec);
104 
105 /* Stop monitoring the given id. */
106 void data_monitor_stop(struct controller_info *cntlr,
107 		       void   *monitor_id);
108 
109 /* Shut down the port, if it is connected. */
110 void disconnect_port(struct controller_info *cntlr,
111 		     char *portspec);
112 
113 struct devio;
114 
115 /* Initialization function for device I/O */
116 int devcfg_init(struct devio *io, struct absout *eout, const char *instr,
117 		int (*otherconfig)(void *data, struct absout *eout,
118 				   const char *item),
119 		void *data);
120 
121 int sol_init(void);
122 void sol_shutdown(void);
123 
124 int solcfg_init(struct devio *io, struct absout *eout, const char *instr,
125 		int (*otherconfig)(void *data, struct absout *eout,
126 				   const char *item),
127 		void *data);
128 
129 struct serial_rs485 *get_rs485_conf(void *data);
130 
131 int add_rotator(char *portname, char *ports, int lineno);
132 void free_rotators(void);
133 
134 #endif /* DATAXFER */
135