lwip_data_event.h 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Copyright (C) 2021 RDA Technologies Limited and/or its affiliates("RDA").
  2. * All rights reserved.
  3. *
  4. * This software is supplied "AS IS" without any warranties.
  5. * RDA assumes no responsibility or liability for the use of the software,
  6. * conveys no license or title under any patent, copyright, or mask work
  7. * right to the product. RDA reserves the right to make changes in the
  8. * software without notification. RDA also make no representation or
  9. * warranty that such application will be suitable for the specified use
  10. * without further testing or modification.
  11. */
  12. #ifndef _LWIP_DATA_EVENT_H_
  13. #define _LWIP_DATA_EVENT_H_
  14. #include <stdint.h>
  15. #include <stddef.h>
  16. #include "lwip/opt.h"
  17. #include "lwip/ip_addr.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. #define TUPLE_PROTOCOL_TCP 0
  22. #define TUPLE_PROTOCOL_UDP 1
  23. #define TUPLE_PROTOCOL_ICMP 2
  24. #define TCP_FIN 0x01U
  25. #define TCP_SYN 0x02U
  26. #define TCP_RST 0x04U
  27. #define TCP_PSH 0x08U
  28. #define TCP_ACK 0x10U
  29. #define TCP_URG 0x20U
  30. #define TCP_ECE 0x40U
  31. #define TCP_CWR 0x80U
  32. typedef struct _five_tuple_t{
  33. uint8_t protocol;
  34. ip_addr_t src_address;
  35. ip_addr_t dst_address;
  36. uint16_t src_port;
  37. uint16_t dst_port;
  38. }five_tuple_t;
  39. typedef struct _event_data_t{
  40. five_tuple_t tuple;
  41. uint32_t reserved;
  42. }event_data_t;
  43. typedef enum _tcp_event_e{
  44. TCP_EVENT_NULL = 0,
  45. TCP_CONNECT,
  46. TCP_DISCONNECT
  47. }tcp_event_e;
  48. typedef struct _tcp_data_t{
  49. event_data_t tuple;
  50. uint8_t tcp_flags;
  51. uint32_t tcp_payload_length;
  52. tcp_event_e tcp_event;
  53. }tcp_data_t;
  54. typedef struct _udp_data_t{
  55. event_data_t tuple;
  56. uint32_t udp_payload_length;
  57. }udp_data_t;
  58. typedef struct _icmp_data_t{
  59. event_data_t tuple;
  60. uint32_t icmp_payload_length;
  61. uint8_t invalid_type;
  62. }icmp_data_t;
  63. typedef void (* data_event_callback)(void *param, event_data_t *event_data);
  64. void lwip_setDataEventCallback(data_event_callback callback, void *param);
  65. #ifdef __cplusplus
  66. }
  67. #endif
  68. #endif // _LWIP_DATA_EVENT_H_