1 /* 2 * Copyright (C) 2002-2010 The DOSBox Team 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 */ 18 19 /* $Id: nullmodem.h,v 1.4 2009-09-25 23:40:47 h-a-l-9000 Exp $ */ 20 21 // include guard 22 #ifndef DOSBOX_NULLMODEM_WIN32_H 23 #define DOSBOX_NULLMODEM_WIN32_H 24 25 #include "dosbox.h" 26 27 #if C_MODEM 28 29 #include "misc_util.h" 30 #include "serialport.h" 31 32 #define SERIAL_SERVER_POLLING_EVENT SERIAL_BASE_EVENT_COUNT+1 33 #define SERIAL_TX_REDUCTION SERIAL_BASE_EVENT_COUNT+2 34 #define SERIAL_NULLMODEM_DTR_EVENT SERIAL_BASE_EVENT_COUNT+3 35 #define SERIAL_NULLMODEM_EVENT_COUNT SERIAL_BASE_EVENT_COUNT+3 36 37 class CNullModem : public CSerial { 38 public: 39 TCPServerSocket* serversocket; 40 TCPClientSocket* clientsocket; 41 42 CNullModem(Bitu id, CommandLine* cmd); 43 ~CNullModem(); 44 bool receiveblock; // It's not a block of data it rather blocks 45 Bit16u serverport; // we are a server if this is nonzero 46 Bit16u clientport; 47 48 Bit8u hostnamebuffer[128]; // the name passed to us by the user 49 50 void updatePortConfig(Bit16u divider, Bit8u lcr); 51 void updateMSR(); 52 void transmitByte(Bit8u val, bool first); 53 void setBreak(bool value); 54 55 void setRTSDTR(bool rts, bool dtr); 56 void setRTS(bool val); 57 void setDTR(bool val); 58 void handleUpperEvent(Bit16u type); 59 60 Bitu rx_state; 61 #define N_RX_IDLE 0 62 #define N_RX_WAIT 1 63 #define N_RX_BLOCKED 2 64 #define N_RX_FASTWAIT 3 65 #define N_RX_DISC 4 66 67 bool doReceive(); 68 void ClientConnect(); 69 void Disconnect(); 70 Bits readChar(); 71 void WriteChar(Bit8u data); 72 73 bool tx_block; // true while the SERIAL_TX_REDUCTION event 74 // is pending 75 76 Bitu rx_retry; // counter of retries 77 78 Bitu rx_retry_max; // how many POLL_EVENTS to wait before causing 79 // a overrun error. 80 81 Bitu tx_gather; // how long to gather tx data before 82 // sending all of them [milliseconds] 83 84 85 bool dtrrespect; // dtr behavior - only send data to the serial 86 // port when DTR is on 87 88 bool transparent; // if true, don't send 0xff 0xXX to toggle 89 // DSR/CTS. 90 91 bool telnet; // Do Telnet parsing. 92 93 // Telnet's brain 94 #define TEL_CLIENT 0 95 #define TEL_SERVER 1 96 97 Bits TelnetEmulation(Bit8u data); 98 99 // Telnet's memory 100 struct { 101 bool binary[2]; 102 bool echo[2]; 103 bool supressGA[2]; 104 bool timingMark[2]; 105 106 bool inIAC; 107 bool recCommand; 108 Bit8u command; 109 } telClient; 110 }; 111 112 #endif // C_MODEM 113 #endif // include guard 114