msousa@0: /* msousa@0: * Copyright (c) 2002,2016 Mario de Sousa (msousa@fe.up.pt) msousa@0: * msousa@0: * This file is part of the Modbus library for Beremiz and matiec. msousa@0: * msousa@0: * This Modbus library is free software: you can redistribute it and/or modify msousa@0: * it under the terms of the GNU Lesser General Public License as published by msousa@0: * the Free Software Foundation, either version 3 of the License, or msousa@0: * (at your option) any later version. msousa@0: * msousa@0: * This program is distributed in the hope that it will be useful, but msousa@0: * WITHOUT ANY WARRANTY; without even the implied warranty of msousa@0: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser msousa@0: * General Public License for more details. msousa@0: * msousa@0: * You should have received a copy of the GNU Lesser General Public License msousa@0: * along with this Modbus library. If not, see . msousa@0: * msousa@0: * This code is made available on the understanding that it will not be msousa@0: * used in safety-critical situations without a full and competent review. msousa@0: */ msousa@0: msousa@0: msousa@0: msousa@0: #ifndef MODBUS_TCP_PRIVATE_H msousa@0: #define MODBUS_TCP_PRIVATE_H msousa@0: msousa@0: msousa@0: #include "mb_util.h" msousa@0: msousa@0: msousa@0: /* tcp port default configuration... */ msousa@0: #define DEF_SERVICE "502" /* port used by modbus */ msousa@0: #define DEF_PROTOCOL "tcp" /* protocol used by modbus tcp */ msousa@0: #define DEF_TYPE SOCK_STREAM /* Quality of service required of the socket... */ msousa@0: #define DEF_MAX_PENDING_CONNECTION_REQUESTS 5 msousa@0: /* maximum number of pending connection requests msousa@0: * that have not yet been accept()'ed msousa@0: */ msousa@0: #define DEF_CLOSE_ON_SILENCE 1 /* Used only by master nodes. msousa@0: * Flag indicating whether, by default, the connection msousa@0: * to the slave device should be closed whenever the msousa@0: * modbus_tcp_silence_init() function is called. msousa@0: * msousa@0: * 0 -> do not close connection msousa@0: * >0 -> close connection msousa@0: * msousa@0: * The spec sugests that connections that will not msousa@0: * be used for longer than 1 second should be closed. msousa@0: * Even though we expect most connections to have msousa@0: * silence intervals much shorted than 1 second, we msousa@0: * decide to use the default of shuting down the msousa@0: * connections because it is safer, and most other msousa@0: * implementations seem to do the same. msousa@0: * If we do not close we risk using up all the possible msousa@0: * connections that the slave can simultaneouly handle, msousa@0: * effectively locking out every other master that msousa@0: * wishes to communicate with that same slave. msousa@0: */ msousa@0: msousa@0: /* Since the receive buffer is also re-used to store the frame header, msousa@0: * we set it to the larger of the two. msousa@0: */ msousa@0: #if TCP_HEADER_LENGTH > MAX_L2_FRAME_LENGTH msousa@0: #define RECV_BUFFER_SIZE TCP_HEADER_LENGTH msousa@0: #else msousa@0: #define RECV_BUFFER_SIZE MAX_L2_FRAME_LENGTH msousa@0: #endif msousa@0: msousa@0: msousa@0: msousa@0: msousa@0: #endif /* MODBUS_TCP_PRIVATE_H */ msousa@0: msousa@0: msousa@0: msousa@0: msousa@0: msousa@0: msousa@0: msousa@0: