blob: 8f90bed05bfca77a2ff8f9ba4464abaebe918d9d [file] [log] [blame]
b.liu9fc00602023-09-24 13:16:50 +08001#include <stdio.h>
2#include <stdlib.h>
3#include <errno.h>
4#include <unistd.h>
5
6#include "mbtk_log.h"
7#include "mbtk_tcpip.h"
8
9typedef struct {
10 int fd;
11 char ser_addr[256];
12 int ser_port;
13 char local_addr[256];
14 int local_port;
15 bool ack_support;
16 bool ssl_support;
17 bool ignore_cert;
18 uint32 heartbeat_time;
19 uint32 delay_time;
20
21 mbtk_tcpip_read_callback_func read_cb;
22
23 uint32 data_traffic_send;
24 uint32 data_traffic_recv;
25
26} mbtk_tcpip_cli_info_t;
27
28typedef struct {
29 int fd;
30 char ser_addr[256];
31 int ser_port;
32
33 int cli_num;
34 mbtk_tcpip_cli_info_t *cli_list;
35} mbtk_tcpip_ser_info_t;
36
37typedef struct {
38 int link_id;
39 int link_cid;
40 bool link_active;
41 mbtk_tcpip_prot_type_enum prot_type; // TCP/UDP
42
43 mbtk_tcpip_type_enum type;
44 union
45 {
46 mbtk_tcpip_cli_info_t cli_info;
47 mbtk_tcpip_ser_info_t ser_info;
48 } tcpip_info;
49
50} mbtk_tcpip_link_t;
51
52static mbtk_tcpip_link_t tcpip_link[MBTK_TCPIP_LINK_MAX];
53
54mbtk_tcpip_err_enum mbtk_tcpip_net_open()
55{
56 return MBTK_TCPIP_ERR_SUCCESS;
57}
58
59mbtk_tcpip_err_enum mbtk_tcpip_net_close()
60{
61 return MBTK_TCPIP_ERR_SUCCESS;
62}
63
64mbtk_tcpip_err_enum mbtk_tcpip_sock_open(const mbtk_tcpip_info_t *tcpip_info)
65{
66 return MBTK_TCPIP_ERR_SUCCESS;
67}
68
69mbtk_tcpip_err_enum mbtk_tcpip_sock_close(int link_id)
70{
71 return MBTK_TCPIP_ERR_SUCCESS;
72}
73
74int mbtk_tcpip_send(int link_id, const char* data, int data_len, const char* ser_addr, int ser_port)
75{
76
77 return 0;
78}
79
80int mbtk_tcpip_read(int link_id, char* buff, int buff_size)
81{
82 return 0;
83}
84
85/*
86* Get the data traffic of the specified link.
87*/
88int mbtk_tcpip_data_traffic_get(int link_id)
89{
90 return 0;
91}
92
93/*
94* Reset the data traffic of the specified link.
95*/
96mbtk_tcpip_err_enum mbtk_tcpip_data_traffic_reset(int link_id)
97{
98 return MBTK_TCPIP_ERR_SUCCESS;
99}
100
101/*
102* Return 0 if disconnected, other for connected.
103*/
104int mbtk_tcpip_link_state_get(int link_id)
105{
106 return 0;
107}
108