sal_msg.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Copyright (c) 2006-2023, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-12-06 zmq810150896 The first version.
  9. */
  10. #ifndef __SAL_MSG_H__
  11. #define __SAL_MSG_H__
  12. #include <rtthread.h>
  13. /* message frame */
  14. struct msg_buf
  15. {
  16. void *parm; /* Parameters for message detection */
  17. void *buf; /* Data to be sent */
  18. rt_size_t length; /* Data length */
  19. void *control_data; /* Additional data to send the message */
  20. rt_size_t data_len; /* Additional data length */
  21. int msg_type; /* message type */
  22. int data_type; /* Addittional data length */
  23. int msg_level;
  24. int *fd; /* Pass the array used by fd */
  25. rt_slist_t msg_next; /* Next message */
  26. rt_slist_t msg_node; /* sendmsg is used to send multiple messages at the same time */
  27. };
  28. /* Remaining message */
  29. struct last_buf
  30. {
  31. void *buf; /* Data to be sent */
  32. rt_size_t length; /* Data length */
  33. rt_size_t offset; /* Data Offset */
  34. struct msg_buf *msg;
  35. };
  36. /* sock */
  37. struct unix_sock
  38. {
  39. rt_uint8_t len;
  40. int flags;
  41. uint8_t family; /* protocol */
  42. char path[108]; /* file name */
  43. struct unix_conn *conn; /* connecting processing */
  44. rt_wqueue_t wq_head; /* Waiting queue head */
  45. rt_atomic_t listen_num; /* Maximum listening quantity */
  46. rt_atomic_t conn_counter; /* connected num */
  47. struct rt_mutex sock_lock;
  48. rt_slist_t wait_conn_head;
  49. struct last_buf pbuf;
  50. };
  51. struct unix_conn
  52. {
  53. int state; /* connect state */
  54. int type;
  55. int proto;
  56. #ifdef SAL_USING_AF_UNIX
  57. rt_atomic_t msg_count;
  58. #endif
  59. rt_uint32_t send_timeout;
  60. rt_uint32_t recv_timeout;
  61. rt_wqueue_t wq_read_head;
  62. rt_wqueue_t wq_confirm;
  63. struct rt_mutex conn_lock;
  64. rt_slist_t msg_head; /* message head */
  65. rt_slist_t conn_node;
  66. struct unix_sock *sock;
  67. struct unix_sock *ser_sock;
  68. struct unix_conn *correl_conn; /* Information about the other party */
  69. int (* conn_callback)(struct unix_conn *conn); /* The callback function that establishes the connection */
  70. };
  71. #endif