tcp_fsm.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. #ifndef _NETINET_TCP_FSM_H_
  2. #define _NETINET_TCP_FSM_H_
  3. /*
  4. * Copyright (C) 2001-2003 by egnite Software GmbH. All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without
  7. * modification, are permitted provided that the following conditions
  8. * are met:
  9. *
  10. * 1. Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. * 2. Redistributions in binary form must reproduce the above copyright
  13. * notice, this list of conditions and the following disclaimer in the
  14. * documentation and/or other materials provided with the distribution.
  15. * 3. Neither the name of the copyright holders nor the names of
  16. * contributors may be used to endorse or promote products derived
  17. * from this software without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  22. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  23. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  24. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  25. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  26. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  27. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  28. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  29. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  30. * SUCH DAMAGE.
  31. *
  32. * For additional information see http://www.ethernut.de/
  33. *
  34. * -
  35. * Portions Copyright (c) 1983, 1993 by
  36. * The Regents of the University of California. All rights reserved.
  37. *
  38. * Redistribution and use in source and binary forms, with or without
  39. * modification, are permitted provided that the following conditions
  40. * are met:
  41. * 1. Redistributions of source code must retain the above copyright
  42. * notice, this list of conditions and the following disclaimer.
  43. * 2. Redistributions in binary form must reproduce the above copyright
  44. * notice, this list of conditions and the following disclaimer in the
  45. * documentation and/or other materials provided with the distribution.
  46. * 3. Neither the name of the University nor the names of its contributors
  47. * may be used to endorse or promote products derived from this software
  48. * without specific prior written permission.
  49. *
  50. * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  51. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  52. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  53. * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  54. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  55. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  56. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  57. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  58. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  59. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  60. * SUCH DAMAGE.
  61. */
  62. /*
  63. * $Log$
  64. * Revision 1.2 2004/07/30 19:36:29 drsung
  65. * Added a comment and changed the prototype of NutTcpStateRetranTimeout.
  66. *
  67. * Revision 1.1.1.1 2003/05/09 14:41:17 haraldkipp
  68. * Initial using 3.2.1
  69. *
  70. * Revision 1.6 2003/02/04 18:00:46 harald
  71. * Version 3 released
  72. *
  73. * Revision 1.5 2002/06/26 17:29:22 harald
  74. * First pre-release with 2.4 stack
  75. *
  76. */
  77. /*!
  78. * \file netinet/tcp_fsm.h
  79. * \brief TCP state machine definitions.
  80. */
  81. #ifdef __cplusplus
  82. extern "C" {
  83. #endif
  84. #define TCP_NSTATES 11 /*!< \brief Total number of possible states. */
  85. /*
  86. * Warning: Do NOT change the values or the order of the TCP states.
  87. * Some functions in tcpsm.c rely on the the order below.
  88. */
  89. #define TCPS_CLOSED 0 /*!< \brief closed */
  90. #define TCPS_LISTEN 1 /*!< \brief listening for connection */
  91. #define TCPS_SYN_SENT 2 /*!< \brief active, have sent syn */
  92. #define TCPS_SYN_RECEIVED 3 /*!< \brief have sent and received syn */
  93. #define TCPS_ESTABLISHED 4 /*!< \brief established */
  94. #define TCPS_CLOSE_WAIT 5 /*!< \brief rcvd fin, waiting for close */
  95. #define TCPS_FIN_WAIT_1 6 /*!< \brief have closed, sent fin */
  96. #define TCPS_CLOSING 7 /*!< \brief closed xchd FIN; await FIN ACK */
  97. #define TCPS_LAST_ACK 8 /*!< \brief had fin and close; await FIN ACK */
  98. #define TCPS_FIN_WAIT_2 9 /*!< \brief have closed, fin is acked */
  99. #define TCPS_TIME_WAIT 10 /*!< \brief in 2*msl quiet wait after close */
  100. #define TCPS_DESTROY 11 /*!< \brief socket marked to be destroyed by the garbage collection */
  101. extern void NutTcpStateMachine(NETBUF *nb);
  102. extern int NutTcpInitStateMachine(void);
  103. extern int NutTcpStatePassiveOpenEvent(TCPSOCKET *sock);
  104. extern int NutTcpStateActiveOpenEvent(TCPSOCKET *sock);
  105. extern int NutTcpStateCloseEvent(TCPSOCKET *sock);
  106. extern int NutTcpStateWindowEvent(TCPSOCKET *sock);
  107. extern int NutTcpStateRetranTimeout(TCPSOCKET *sock);
  108. #ifdef __cplusplus
  109. }
  110. #endif
  111. #endif