ql_ping_app.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*================================================================
  2. Copyright (c) 2021, Quectel Wireless Solutions Co., Ltd. All rights reserved.
  3. Quectel Wireless Solutions Proprietary and Confidential.
  4. =================================================================*/
  5. #ifndef QL_PING_APP_H
  6. #define QL_PING_APP_H
  7. #if 1//def CONFIG_QUEC_PROJECT_FEATURE_TCPIP
  8. typedef enum{
  9. QL_PING_OK = 0,
  10. QL_PING_ERR_UNKNOW = (QL_COMPONENT_LWIP_SOCKET << 16) | 550 /* Unknow ERROR */,
  11. QL_PING_ERR_INVALID_PARAM = (QL_COMPONENT_LWIP_SOCKET << 16) | 552 /* Invalid parameters */,
  12. QL_PING_ERR_SOCKET_NEW_FAILURE = (QL_COMPONENT_LWIP_SOCKET << 16) | 554 /* Create socket failed */,
  13. QL_PING_ERR_SOCKET_BIND_FAILURE = (QL_COMPONENT_LWIP_SOCKET << 16) | 556 /* Socket bind failed */,
  14. QL_PING_ERR_DNS_FAILURE = (QL_COMPONENT_LWIP_SOCKET << 16) | 565 /* DNS parse failed */,
  15. QL_PING_ERR_TIMEOUT = (QL_COMPONENT_LWIP_SOCKET << 16) | 569 /* Operation timeout */,
  16. }ql_ping_result_code;
  17. typedef struct
  18. {
  19. uint32_t num_data_bytes; /* Data byte size of the ping packet */
  20. uint32_t ping_response_time_out; /* Wait time for ping response, ms */
  21. uint32_t num_pings; /* Number of times to ping */
  22. uint32_t ttl; /* Time To Live for the ping packet */
  23. } ql_ping_config_type;
  24. typedef enum{
  25. QL_PING_STATS = 1,
  26. QL_PING_SUMMARY = 2,
  27. }ql_ping_event_type;
  28. typedef struct{
  29. uint32_t ping_rtt;
  30. uint32_t ping_size;
  31. uint32_t ping_ttl;
  32. char resolved_ip_addr[256];
  33. }ql_ping_stats_type;
  34. typedef struct{
  35. uint32_t min_rtt; /* Minimum RTT so far, in millisecs */
  36. uint32_t max_rtt; /* Maximum RTT so far, in millisecs */
  37. uint32_t avg_rtt; /* Average RTT so far, in millisecs */
  38. uint32_t num_pkts_sent; /* Number of pings sent so far */
  39. uint32_t num_pkts_recvd; /* Number of responses recieved so far */
  40. uint32_t num_pkts_lost; /* Number of responses not received */
  41. }ql_ping_summary_type;
  42. typedef int ping_session_id;
  43. typedef void(*ql_ping_event_cb)(ping_session_id ping_sess_id, uint16_t event_id, int evt_code, void *evt_param);
  44. /*****************************************************************
  45. * Function: ql_ping_start
  46. *
  47. * Description: 启用ping功能,根据配置参数设置发送的ping包
  48. *
  49. * Parameters:
  50. * cid [in] pdp cid信息.
  51. * sim_id [in] sim id信息
  52. * host [in] ping操作的对端地址
  53. * ping_options [in] ping请求发送数据设置,请求字节数,超时时间,最大请求次数
  54. * cb_fcn [in] ping操作的事件回调函数,设置事件类型为ping start,以及对ping回调结果的判断处理
  55. *
  56. * Return:
  57. * ping事件会话id
  58. *
  59. *****************************************************************/
  60. ping_session_id ql_ping_start(int cid, int sim_id, const char *host, ql_ping_config_type *ping_options , ql_ping_event_cb cb_fcn);
  61. /*****************************************************************
  62. * Function: ql_ping_stop
  63. *
  64. * Description: 返回固定结果值1
  65. *
  66. * Parameters:
  67. * ping_sess_id [in] ping事件会话id.
  68. *
  69. * Return:
  70. * 1 返回固定结果1
  71. *
  72. *****************************************************************/
  73. int ql_ping_stop(ping_session_id ping_sess_id);
  74. #endif
  75. #endif