| #ifndef __MBTK_AT_TCPIP_H__ |
| #define __MBTK_AT_TCPIP_H__ |
| |
| #include <pthread.h> |
| /*******************DEFINE**********************/ |
| #define task_mutex pthread_mutex_t |
| /*******************DEFINE**********************/ |
| |
| /*******************TYPEDEF**********************/ |
| typedef void (*mbtk_tcpip_read_callback_func)(int link_id, const char* data, int data_len); |
| /*******************TYPEDEF**********************/ |
| |
| /*******************ENUM**********************/ |
| typedef enum { |
| MBTK_TCPIP_ERR_SUCCESS, |
| MBTK_TCPIP_ERR_NET_UNAVAILABLE, /* Network unavailable. */ |
| MBTK_TCPIP_ERR_NET_HANDLE, /* Network handle error. */ |
| MBTK_TCPIP_ERR_ARG, /* Parameter error. */ |
| MBTK_TCPIP_ERR_LINK_UNAVAILABLE, /* Link unavailable. */ |
| MBTK_TCPIP_ERR_LINK_NOT_CONNECT, /* Link not connect. */ |
| MBTK_TCPIP_ERR_UNKNOWN |
| } mbtk_tcpip_err_enum; |
| |
| typedef enum |
| { |
| MBTK_SOCK_TCP = 0, |
| MBTK_SOCK_UDP |
| } mbtk_sock_type; |
| |
| typedef enum { |
| MBTK_TCPIP_TYPE_CLIENT, |
| MBTK_TCPIP_TYPE_SERVER |
| } mbtk_tcpip_type_enum; |
| /*******************ENUM**********************/ |
| |
| /*******************STRUCT**********************/ |
| typedef struct |
| { |
| unsigned int sig; |
| void* payload; |
| } mbtk_signal_info; |
| |
| |
| typedef struct{ |
| task_mutex crit_sect; //User-defined data type |
| } mbtk_mutex; |
| |
| typedef struct node |
| { |
| void *payload; |
| int count; //only used to count for internal |
| mbtk_mutex mutex; //only used to count for internal |
| struct node *front; |
| struct node *rear; |
| } mbtk_queue_node_t; |
| |
| typedef struct { |
| pthread_t thread_id; |
| pthread_cond_t cond; |
| mbtk_mutex mutex; |
| mbtk_queue_node_t queue; |
| } mbtk_task_queue_info; |
| |
| typedef struct { |
| int link_id; |
| char ser_addr[256]; |
| int ser_port; |
| mbtk_sock_type prot_type; // TCP/UDP |
| mbtk_tcpip_type_enum tcpip_type; // Only support client. |
| int local_port; |
| bool ack_support; |
| bool ssl_support; |
| bool ignore_cert; |
| uint32 heartbeat_time; |
| uint32 delay_time; |
| |
| mbtk_tcpip_read_callback_func read_cb; |
| } mbtk_tcpip_info_t; |
| |
| typedef struct { |
| int link_id; |
| int sock_fd; |
| int state; |
| int recv_data_len; |
| } mbtk_tcpip_tcp_state_info_s; |
| /*******************STRUCT**********************/ |
| |
| |
| |
| #endif |