blob: 11e3dcad78a00e1762de502db44e46427a00f59f [file] [log] [blame]
lh9ed821d2023-04-07 01:36:19 -07001/**
2 * @file ext_socket_func.h
3 * @brief ÌṩÁËÆ½Ì¨ÄÚ²¿ÏûÏ¢ºÍÏûÏ¢½á¹¹¶¨Ò壬°üÀ¨at_ctlÓëÆ½Ì¨ÄÚ²¿Ä£¿é½»»¥µÄÏûÏ¢µÈ
4 *
5 * Copyright (C) 2017 Sanechips Technology Co., Ltd.
6 * @author
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11 *
12 */
13#ifndef __EXT_SOCKET_FUNC_H__
14#define __EXT_SOCKET_FUNC_H__
15
16/*******************************************************************************
17 * Include header files *
18 ******************************************************************************/
19#include "arpa/inet.h"
20
21#include "ext_ftp_func.h"
22/*******************************************************************************
23 * Macro definitions *
24 ******************************************************************************/
25
26
27/*******************************************************************************
28 * Type definitions *
29 ******************************************************************************/
30
31
32//¹úµçsocket
33
34#define UNIX_SOCKET_SERVER "socket_proxy_server"
35
36#define NON_TRANSPARENT_MODE 0 //·Ç͸Ã÷´«Êä
37#define TRANSPARENT_MODE 1 //͸Ã÷´«Êä
38
39#define CONN_TYPE_TCP_C 0 //tcp ¿Í»§¶Ë
40#define CONN_TYPE_TCP_S 1 //tcp ·þÎñ¶Ë
41#define CONN_TYPE_UDP 2 //udp
42#define IP_FILTER_NUM 5
43#define MAX_WRITE_LEN 1460
44#define MAX_WRITE_LEN_NANDIAN 2000
45#define AP_LOCK "ap_lock"
46
47struct comm_rspmsg {
48 int ret;
49 int err;
50 int socketid;
51 int len;
52 int viewmode;
53 int remote_mss;
54};
55
56struct comm_reqmsg {
57 int socketid;
58 int len;
59};
60
61struct netsrv_msg {
62 int ch_id;
63 int socketid;
64 int conn_type;
65 int viewMode;
66 char ipport[128];
67};
68struct netcreate_msg {
69 int ch_id;
70 int mode;
71 int socketid;
72 char remote_ip[128];
73 int remote_port;
74 int local_port;
75};
76struct netcreate_rspmsg {
77 int ret;
78 int err;
79 int socketid;
80 int mode;
81};
82struct netping_reqmsg {
83 char remote_ip[128];
84 int try_count;
85 int packet_size;
86};
87
88struct netping_rspmsg {
89 int ret;
90 int err;
91 int try_count;
92 int total_recv;
93 int packet_size;
94 char remote_ip[128];
95 int echo_rep_ttl;
96 char round_trip_sta[100];
97};
98struct netaccept_reqmsg {
99 int socketid;
100 int action;//ÊÇ·ñ½ÓÊÜÕìÌý 0-½ÓÊÜ 1-¾Ü¾ø
101 int transportMode;//ÕìÌý³É¹¦ºóµÄ´«Êäģʽ 0-·Ç͸Ã÷´«Êäģʽ 1-͸Ã÷´«Êäģʽ
102};
103struct netaccept_rspmsg {
104 int ret;
105 int err;
106 int socketid;
107 int transportMode;//ÕìÌý³É¹¦ºóµÄ´«Êäģʽ 0-·Ç͸Ã÷´«Êäģʽ 1-͸Ã÷´«Êäģʽ
108};
109struct netcon_reqmsg {
110 int extcid;//Ìṩ¸øÍⲿʹÓõÄcidÖµ£¬Ö§³Ö1-16
111 int is_userpwd;//ÓÉÓÚÓû§ÃûºÍÃÜÂë¿ÉÄÜΪ¿Õ£¬ÐèÒª¸Ã±ê־λָʾµ±Ç°ÅäÖÃÊÇ·ñÊÇÓû§ÃûºÍÃÜÂëÅäÖÃ
112 int cfgt;//ÿ°ü·¢Ë͵ȴýʱ¼ä
113 int cfgp;//Êý¾Ý°ü±»·¢Ë͵ÄÃÅÏÞÖµ
114 char apn[70];//Íⲿͨ¹ýÀ©Õ¹atÃüÁîÉèÖõÄapn
115 int auth_type;//Íⲿͨ¹ýÀ©Õ¹atÃüÁîÉèÖÃÈÏÖ¤ÀàÐÍ
116 char username[65];//Íⲿͨ¹ýÀ©Õ¹atÃüÁîÉèÖõÄÓû§Ãû
117 char password[65];//Íⲿͨ¹ýÀ©Õ¹atÃüÁîÉèÖõÄÃÜÂë
118};
119struct netact_reqmsg {
120 int act_type;// 1±íʾ¼¤»î²Ù×÷£¬0±íʾȥ¼¤»î²Ù×÷
121 int extcid; //Ö¸¶¨½øÐ줻î»òÕßÈ¥¼¤»îµÄÍⲿcid
122};
123
124struct neturc_reqmsg {
125 int on_off;// 0-¹Ø±ÕЭÒéÕ»Ö÷¶¯Éϱ¨ 1-´ò¿ªÐ­ÒéÕ»Ö÷¶¯Éϱ¨
126};
127struct ipfilter_reqmsg {
128 int id;
129 int action;
130 char ip_address[128];
131 char net_mask[128];
132};
133struct netack_rspmsg {
134 int ret;
135 int err;
136 int socketid;
137 int unacked_datalen;
138 int rest_bufferlen;
139};
140struct type_rspmsg {
141 int mode;
142 int network_type;
143 int extended_feature;
144};
145struct netact_query_rspmsg {
146 int channel;
147 int status;
148 char ip[128];
149};
150struct neturc_query_rspmsg {
151 int on_off;// 0-¹Ø±ÕЭÒéÕ»Ö÷¶¯Éϱ¨ 1-´ò¿ªÐ­ÒéÕ»Ö÷¶¯Éϱ¨
152};
153struct ipfilter_config_info {
154 int id;
155 char ip_address[128];
156 char net_mask[128];
157};
158struct ipfilter_query_rspmsg {
159 int num;
160 struct ipfilter_config_info ipfilter_info[IP_FILTER_NUM];
161};
162struct netopen_query_rspmsg {
163 int ret;
164 int socket_id;
165 char local_ip[128];
166 int local_port;
167 char gate[128];
168 char dns1[128];
169 char dns2[128];
170 int type;
171 char dest_ip[128];
172 int dest_prot;
173};
174
175
176
177
178//quectel socket
179
180#define MAX_SOCKET_SERVICE_NUM 12
181#define MAX_CONTEXT_NUM 16
182
183#define MAX_SEND_LEN 1024
184#define MAX_READ_LEN 1500
185#define MAX_SEND_HEX_LEN 512
186#define MAX_PING_NUM 10
187
188
189
190/*·þÎñÀàÐÍ */
191enum service_type {
192 TCP,
193 UDP,
194 TCP_LISTENER,
195 UDP_SERVICE
196};
197/*Êý¾Ý´«ÊäÀàÐÍ */
198enum access_mode {
199 BUFFER_ACCESS_MODE,
200 DIRECT_PUSH_MODE,
201 TRANSPARENT_ACCESS_MODE
202};
203/*͸Ã÷´«ÊäģʽÏÂÊý¾Ýģʽ/ÃüÁîģʽ */
204enum data_mode_or_cmd_mode {
205 TM_DATA_MODE,
206 TM_CMD_MODE
207};
208
209/*socket״̬*/
210enum socket_state {
211 INITIAL_STATE,
212 OPENING_STATE,
213 CONNECTED_STATE,
214 LISTENING_STATE,
215 CLOSING_STATE
216};
217
218/*²éѯÁ´½Ó״̬µÄÀàÐÍ */
219enum query_type {
220 QUERY_CONNECTION_STATUS_BY_CONTEXTID,
221 QUERY_CONNECTION_STATUS_BY_CONNECTID
222};
223
224/*Êý¾Ý·¢ËÍ»ò½ÓÊÕµÄÀàÐÍ */
225enum data_type {
226 CHANGEABLE_LENGTH,
227 FIXED_LENGTH,
228 UDP_DATA,
229 QUERY_DATA_INFO
230};
231
232/*Êý¾Ý·¢Ë͵Ľá¹û */
233enum send_rsp {
234 SEND_OK,
235 SEND_FAIL,
236 SEND_ERROR,
237 READY_TO_SEND
238};
239/*Êý¾Ý½ÓÊյĽá¹û */
240enum read_rsp {
241 READ_OK,
242 NODATA_READ,
243 CONNECTION_EXIST,
244 CONNECTION_NOT_EXIST
245};
246/*ģʽÇл»µÄ½á¹û */
247enum swtmd_rsp {
248 SW_SUCC,
249 SW_FAIL
250};
251enum dns_action_req {
252 DNS_CFG_WITH_SECDNSADDR,
253 DNS_CFG_NO_SECDNSADDR,
254 DNS_QUERY
255};
256enum dns_action_rsp {
257 DNS_ACTION_SUCC,
258 DNS_ACTION_FAIL
259};
260struct quectel_sock_info {
261 int socket;//Ó¦ÓÃÖÐÕæÊµ´´½¨µÄsocket¾ä±ú
262 int connect_id;//
263 char service_type[20];//
264 struct in_addr ip_addr; //ipµØÖ·
265 int remote_port;//Ô¶¶Ëport
266 int local_port; //±¾µØport
267 int socket_state;
268 int context_id;
269 int server_id;
270 int access_mode;
271 int at_port;
272 int total_send_length;
273 int ackedbytes;
274 int unackedbytes;
275 int total_rcv_length;
276 int have_read_length;
277 int unread_length;
278};
279
280struct each_ping_req_result {
281 int result;
282 char remote_ip[128];
283 int ping_len;
284 int response_time;//in ms
285 int ttl;
286};
287
288struct quectel_comm_reqmsg {
289 int connect_id;
290 int len;
291};
292struct quectel_comm_rspmsg {
293 int ret;
294 int err;
295 int connect_id;
296 int access_mode;
297 //int len;
298};
299
300struct quectel_qiclose_reqmsg {
301 int connect_id;
302 //int len;
303 int timeout;
304};
305
306struct quectel_qisend_reqmsg {
307 int send_type;//0-changeable length 1-fixed length 2-udp send 3-query
308 int connect_id;
309 int len;
310 char ip_addr[128];
311 int remote_port;
312};
313
314struct quectel_qisend_rspmsg {
315 int send_type;//0-changeable length 1-fixed length 2-udp send 3-query
316 int ret;
317 int connect_id;
318 int total_send_length;
319 int ackedbytes;
320 int unackedbytes;
321};
322struct quectel_qisendex_reqmsg {
323 int connect_id;
324 char hex_data[MAX_SEND_HEX_LEN];
325};
326struct quectel_qird_reqmsg {
327 int read_type;//0-changeable length 1-fixed length 2-query
328 int connect_id;
329 int len;
330};
331
332struct quectel_qird_rspmsg {
333 int read_type;//0-changeable length 1-fixed length 2-query
334 int service_type;
335 int ret;
336 int read_actual_length;
337 char remote_ipaddr[128];
338 int remote_port;
339 int total_rcv_length;
340 int have_read_length;
341 int unread_length;
342 //int ackedbytes;
343 //int unackedbytes;
344 char data[MAX_READ_LEN];
345};
346struct quectel_qiopen_msg {
347 int context_id;
348 int connect_id;
349 char service_type[20];
350 char ip_addr[128];
351 int remote_port;
352 int local_port;
353 int access_mode;
354};
355struct quectel_qistate_reqmsg {
356 int query_type;
357 int query_id;
358};
359struct quectel_qistate_rspmsg {
360 int num;
361 int query_type;
362 struct quectel_sock_info query_status_info[MAX_SOCKET_SERVICE_NUM];
363};
364
365struct quectel_qiswtmd_reqmsg {
366 int connect_id;
367 int access_mode;
368};
369struct quectel_qiswtmd_rspmsg {
370 int ret;
371 int access_mode;
372};
373struct quectel_qidnscfg_reqmsg {
374 int action_type;//0-config 1-query
375 int context_id;
376 char pri_dns_addr[128];
377 char sec_dns_addr[128];
378};
379struct quectel_qidnscfg_rspmsg {
380 int action_type;//0-config 1-query
381 int ret;
382 int context_id;
383 char pri_dns_addr[128];
384 char sec_dns_addr[128];
385};
386struct quectel_qidnsgip_reqmsg {
387 int context_id;
388 char host_name[128];
389};
390struct quectel_qidnsgip_rspmsg {
391 int ret;
392 int error;
393 int ip_count;
394 int dns_ttl;
395 char host_ipaddr[4][128];
396};
397struct quectel_qigeterror_rspmsg {
398 int err;
399 char errcode_description[32];
400};
401struct qping_reqmsg {
402 int context;
403 char remote_ip[128];
404 int timeout;
405 int ping_num;
406};
407
408struct qping_rspmsg {
409 int ret;
410 int ping_num;
411 struct each_ping_req_result each_ping_result[MAX_PING_NUM];
412 int finresult;
413 int sent;
414 int rcvd;
415 int lost;
416 int min;
417 int max;
418 int avg;
419};
420struct quectel_qiurc_rspmsg {
421 int buffer_mode;
422 int service_type;
423 int connect_id;
424 int currentrecvlength;
425 char remote_ipaddr[128];
426 int remote_port;
427 char data[MAX_READ_LEN];
428};
429/*ÍøÂçͬ²½ÐźŵƿØÖÆ£¬ÓÃÓÚÍâÖÃЭÒéÕ»socketÁ¬½Ó³É¹¦Ê±£¬LEDÐźŵÆÉÁ˸¿ØÖÆ*/
430struct zteftp_socketled_reqmsg {
431 int iswitch;/*0±íʾsocketδÁ¬½ÓʱLEDÉÁ˸״̬£»1±íʾsocketÁ¬½Ó³É¹¦Ê±£¬LEDÉÁµÆ£»*/
432};
433struct zteftp_socketled_rspmsg {
434 int result;/*0±íʾOK£»-1±íʾERROR*/
435};
436#endif