evnt_handler.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. /*****************************************************************************
  2. *
  3. * evnt_handler.h - CC3000 Host Driver Implementation.
  4. * Copyright (C) 2011 Texas Instruments Incorporated - http://www.ti.com/
  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. * Redistributions of source code must retain the above copyright
  11. * notice, this list of conditions and the following disclaimer.
  12. *
  13. * Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in the
  15. * documentation and/or other materials provided with the
  16. * distribution.
  17. *
  18. * Neither the name of Texas Instruments Incorporated nor the names of
  19. * its contributors may be used to endorse or promote products derived
  20. * from this software without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  23. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  24. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  25. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  26. * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  27. * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  28. * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  29. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  30. * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  31. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  32. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. *****************************************************************************/
  35. #ifndef __CC3000_EVENT_HANDLER_H__
  36. #define __CC3000_EVENT_HANDLER_H__
  37. #include "hci.h"
  38. #include "socket.h"
  39. //*****************************************************************************
  40. //
  41. // If building with a C++ compiler, make all of the definitions in this header
  42. // have a C binding.
  43. //
  44. //*****************************************************************************
  45. #ifdef __cplusplus
  46. extern "C" {
  47. #endif
  48. //*****************************************************************************
  49. //
  50. // Prototypes for the APIs.
  51. //
  52. //*****************************************************************************
  53. //*****************************************************************************
  54. //
  55. //! hci_event_handler
  56. //!
  57. //! @param pRetParams incoming data buffer
  58. //! @param from from information (in case of data received)
  59. //! @param fromlen from information length (in case of data received)
  60. //!
  61. //! @return none
  62. //!
  63. //! @brief Parse the incoming events packets and issues corresponding
  64. //! event handler from global array of handlers pointers
  65. //
  66. //*****************************************************************************
  67. extern UINT8 *hci_event_handler(void *pRetParams, UINT8 *from, UINT8 *fromlen);
  68. //*****************************************************************************
  69. //
  70. //! hci_unsol_event_handler
  71. //!
  72. //! @param event_hdr event header
  73. //!
  74. //! @return 1 if event supported and handled
  75. //! 0 if event is not supported
  76. //!
  77. //! @brief Handle unsolicited events
  78. //
  79. //*****************************************************************************
  80. extern INT32 hci_unsol_event_handler(CHAR *event_hdr);
  81. //*****************************************************************************
  82. //
  83. //! hci_unsolicited_event_handler
  84. //!
  85. //! @param None
  86. //!
  87. //! @return ESUCCESS if successful, EFAIL if an error occurred
  88. //!
  89. //! @brief Parse the incoming unsolicited event packets and issues
  90. //! corresponding event handler.
  91. //
  92. //*****************************************************************************
  93. extern INT32 hci_unsolicited_event_handler(void);
  94. #define M_BSD_RESP_PARAMS_OFFSET(hci_event_hdr)((CHAR *)(hci_event_hdr) + HCI_EVENT_HEADER_SIZE)
  95. #define SOCKET_STATUS_ACTIVE 0
  96. #define SOCKET_STATUS_INACTIVE 1
  97. /* Init socket_active_status = 'all ones': init all sockets with SOCKET_STATUS_INACTIVE.
  98. Will be changed by 'set_socket_active_status' upon 'connect' and 'accept' calls */
  99. #define SOCKET_STATUS_INIT_VAL 0xFFFF
  100. #define M_IS_VALID_SD(sd) ((0 <= (sd)) && ((sd) <= 7))
  101. #define M_IS_VALID_STATUS(status) (((status) == SOCKET_STATUS_ACTIVE)||((status) == SOCKET_STATUS_INACTIVE))
  102. extern UINT32 socket_active_status;
  103. extern void set_socket_active_status(INT32 Sd, INT32 Status);
  104. extern INT32 get_socket_active_status(INT32 Sd);
  105. typedef struct _bsd_accept_return_t
  106. {
  107. INT32 iSocketDescriptor;
  108. INT32 iStatus;
  109. sockaddr tSocketAddress;
  110. } tBsdReturnParams;
  111. typedef struct _bsd_read_return_t
  112. {
  113. INT32 iSocketDescriptor;
  114. INT32 iNumberOfBytes;
  115. UINT32 uiFlags;
  116. } tBsdReadReturnParams;
  117. #define BSD_RECV_FROM_FROMLEN_OFFSET (4)
  118. #define BSD_RECV_FROM_FROM_OFFSET (16)
  119. typedef struct _bsd_select_return_t
  120. {
  121. INT32 iStatus;
  122. UINT32 uiRdfd;
  123. UINT32 uiWrfd;
  124. UINT32 uiExfd;
  125. } tBsdSelectRecvParams;
  126. typedef struct _bsd_getsockopt_return_t
  127. {
  128. UINT8 ucOptValue[4];
  129. CHAR iStatus;
  130. } tBsdGetSockOptReturnParams;
  131. typedef struct _bsd_gethostbyname_return_t
  132. {
  133. INT32 retVal;
  134. INT32 outputAddress;
  135. } tBsdGethostbynameParams;
  136. //*****************************************************************************
  137. //
  138. // Mark the end of the C bindings section for C++ compilers.
  139. //
  140. //*****************************************************************************
  141. #ifdef __cplusplus
  142. }
  143. #endif // __cplusplus
  144. #endif // __CC3000_EVENT_HANDLER_H__