TriOS/lib/driver_socket.spin

1 line
44 KiB
Plaintext
Raw Normal View History

{{ Ethernet TCP/IP Socket Layer Driver (IPv4) ------------------------------------------ Copyright (c) 2006-2009 Harrison Pham <harrison@harrisonpham.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. The latest version of this software can be obtained from http://hdpham.com/PropTCP and http://obex.parallax.com/}}'' NOTICE: All buffer sizes must be a power of 2!CON' ***************************************' ** Versioning Information **' *************************************** version = 5 ' major version release = 2 ' minor version apiversion = 8 ' api compatibility version' ***************************************' ** User Definable Settings **' *************************************** sNumSockets = 4 ' max number of concurrent registered sockets (max of 255)' *** End of user definable settings, don't edit anything below this line!!!' *** All IP/MAC settings are defined by calling the start(...) methodCON' ***************************************' ** Return Codes / Errors **' *************************************** RETBUFFEREMPTY = -1 ' no data available RETBUFFERFULL = -1 ' buffer full ERRGENERIC = -1 ' generic errors ERR = -100 ' error codes start at -100 ERRBADHANDLE = ERR - 1 ' bad socket handle ERROUTOFSOCKETS = ERR - 2 ' no free sockets available ERRSOCKETCLOSED = ERR - 3 ' socket closed, could not perform operationOBJ nic : "driver_enc28j60" 'ser : "SerialMirror" 'stk : "Stack Length"CON' ***************************************' ** Socket Constants and Offsets **' ***************************************' Socket states (user should never touch these) SCLOSED = 0 ' closed, handle not used SLISTEN = 1 ' listening, in server mode SSYNSENT = 2 ' SYN sent, server mode, waits for ACK SSYNSENTCL = 3 ' SYN sent, client mode, waits for SYN+ACK SESTABLISHED = 4 ' established connection (either SYN+ACK, or ACK+Data) SCLOSING = 5 ' connection is being forced closed by code SCLOSING2 = 6 ' closing, we are waiting for a fin now SFORCECLOSE = 7 ' force connection close (just RSTs, no waiting for FIN or anything) SCONNECTINGARP1 = 8 ' connecting, next step: send arp request SCONNECTINGARP2 = 9 ' connecting, next step: arp request sent, waiting for response SCONNECTINGARP2G = 10 ' connecting, next step: arp request sent, waiting for response [GATEWAY REQUEST] SCONNECTING = 11 ' connecting, next step: got mac address, send SYN' ***************************************' ** TCP State Management Constants **' *************************************** TIMEOUTMS = 500 ' (milliseconds) timeout before a retransmit occurs RSTTIMEOUTMS = 2000 ' (milliseconds) timeout before a RST is sent to close the connection WINDOWUPDATEMS = 25 ' (milliseconds) window adve