CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/external/cache/sources/wl/shared/wlu_remote.h
Views: 3959
1
/*
2
* OS independent remote wl declarations
3
*
4
* $Copyright (C) 2008 Broadcom Corporation$
5
*
6
* $Id: wlu_remote.h 401759 2013-05-13 16:08:08Z sudhirbs $
7
*/
8
#ifndef _wlu_remote_h
9
#define _wlu_remote_h
10
#include <wlioctl.h>
11
/* Remote wl declararions */
12
#define NO_REMOTE 0
13
#define REMOTE_SERIAL 1
14
#define REMOTE_SOCKET 2
15
#define REMOTE_WIFI 3
16
#define REMOTE_DONGLE 4
17
#define SHELL_CMD -1 /* Invalid cmd id for shell */
18
#define ASD_CMD -2 /* Cmd id for ASD command */
19
#define SERVER_RESPONSE_MAX_BUF_LEN 8192
20
#define SHELL_RESP_SIZE 1024
21
#define CTRLC_PACKET 0xDEADBEAF
22
#define CTRLC_FLAG -4
23
#define VISTA_CMD -3 /* cmd id for remote vista */
24
25
/* For cross OS support */
26
/* For autonegotiation to work, these defines should be
27
* the same for client and server.
28
*/
29
#define UNKNOWN_OS 0
30
#define LINUX_OS 1
31
#define WIN32_OS 2
32
#define MAC_OSX 3
33
#define BACKLOG 4
34
#define WINVISTA_OS 5
35
#define INDONGLE 6
36
#define INVALID_OS 7 /* Should be last */
37
38
/* Used in cdc_ioctl_t.flags field */
39
#define REMOTE_SET_IOCTL 1
40
#define REMOTE_GET_IOCTL 2
41
#define REMOTE_REPLY 4
42
#define REMOTE_SHELL_CMD 8
43
#define REMOTE_FINDSERVER_IOCTL 16 /* Find remote server */
44
#define REMOTE_ASD_CMD 32 /* ASD integration */
45
#define RDHD_SET_IOCTL 64
46
#define RDHD_GET_IOCTL 128
47
#define REMOTE_VISTA_CMD 256 /* for remote vista specific commands */
48
#define REMOTE_NEGOTIATE_CMD 512 /* for RWL negotiation */
49
#define NEGOTIATE_GET_OS 0 /* detect remote OS */
50
#define RWL_WIFI_DEFAULT_TYPE 0x00
51
#define RWL_WIFI_DEFAULT_SUBTYPE 0x00
52
#define RWL_ACTION_FRAME_DATA_SIZE 1024 /* fixed size for the wifi frame data */
53
#define RWL_WIFI_CDC_HEADER_OFFSET 0
54
#define RWL_WIFI_FRAG_DATA_SIZE 960 /* max size of the frag data */
55
#define RWL_DEFAULT_WIFI_FRAG_COUNT 127 /* maximum fragment count */
56
#define RWL_WIFI_RETRY 5 /* CMD retry count for wifi */
57
#define RWL_WIFI_RX_RETRY 20 /* WIFI response rerty count */
58
#define RWL_WIFI_SEND 5 /* WIFI frame sent count */
59
#define RWL_WIFI_RETRY_DELAY 1000 /* wifi specific retry delay */
60
#define RWL_WIFI_SEND_DELAY 100 /* delay between two frames */
61
#define RWL_WIFI_RX_DELAY 250 /* wait between send and receive */
62
#define RWL_WIFI_RX_SHELL_DELAY 1000 /* delay added for shell cmd response read */
63
#define RWL_CHANNEL_RX_SCAN_DELAY 10 /* Delay between findserver rx calls */
64
#define RWL_CHANNEL_SCAN_WAIT 250 /* Sleep time in between the channel scans */
65
#define RWL_WIFI_BUF_LEN 64
66
#define RWL_WIFI_SHELL_CMD 1
67
#define RWL_WIFI_WL_CMD 0
68
#define RWL_WIFI_FIND_SER_CMD "findserver"
69
#define RWL_WIFI_ACTION_CMD "wifiaction"
70
#define RWL_WIFI_GET_ACTION_CMD "rwlwifivsaction"
71
#define RWL_DONGLE_SET_CMD "dongleset"
72
#define DATA_FRAME_LEN 960
73
/* wl & shell cmd work fine for 960 (512+256+128+64) */
74
75
76
/*
77
* Information about the action frame data fields in the
78
* dot11_action_wifi_vendor_specific
79
* cdc struct (1 to 16. This does not include status flag. Since this
80
* is not directly visible to the driver code we cant use sizeof struct
81
* cdc_ioctl_t. Hence Ref MAC address offset starts from byte 17.
82
* REF MAC ADDR (6 bytes (MAC Address len) from byte 17 to 22)
83
* DUT MAC ADDR (6 bytes after the REF MAC Address byte 23 to 28)
84
* unused (byte 29 to 49)
85
* REF/Client Channel offset (50)
86
* DUT/Server channel offset (51)
87
* ---------------------------------------------------------------------------------------
88
* cdc struct|REF MAC ADDR|DUT_MAC_ADDR|un used|REF Channel|DUT channel|Action frame Data|
89
* 1---------17-----------23-------------------50----------51----------52----------------1040
90
* REF MAC addr after CDC struct without status flag (status flag not used by wifi)
91
*/
92
#define RWL_ACTION_WIFI_CATEGORY 127 /* Vendor Specific category value for wifi */
93
#define RWL_REF_MAC_ADDRESS_OFFSET 17
94
#define RWL_DUT_MAC_ADDRESS_OFFSET 23
95
#define RWL_WIFI_CLIENT_CHANNEL_OFFSET 50
96
#define RWL_WIFI_SERVER_CHANNEL_OFFSET 51
97
98
#define SUCCESS 1
99
#define FAIL -1
100
#define NO_PACKET -2
101
#define SERIAL_PORT_ERR -3
102
103
#define DEFAULT_SERVER_PORT 8000
104
105
#define WL_MAX_BUF_LEN (127 * 1024)
106
#define MAX_VISTA_ARGC 10
107
#define HOST_TO_NETWORK TRUE
108
#define NETWORK_TO_HOST FALSE
109
110
#ifndef IFNAMSIZ
111
#define IFNAMSIZ 16
112
#endif
113
114
#if defined (WIN32) || defined (LINUX)
115
/* We don't want the server to allocate bigger buffers for some of the commands
116
* like scanresults. Server can still allocate 8K memory and send the response
117
* in fragments. This is used in case of Get commands only.
118
*/
119
#define SERVER_RESPONSE_MAX_BUF_LEN 8192
120
#endif
121
/* Used to set the cmds for wifi specific init */
122
typedef struct remote_wifi_cmds {
123
uint32 cmd; /* common ioctl definition */
124
char *data; /* max size of the data length */
125
int value;
126
} remote_wifi_cmds_t;
127
128
/* Added for debug utility support */
129
#define ERR stderr
130
#define OUTPUT stdout
131
132
#define DEBUG_DEFAULT 0x0001
133
#define DEBUG_ERR 0x0001
134
#define DEBUG_INFO 0x0002
135
#define DEBUG_DBG 0x0004
136
137
/* #ifdef TARGETOS_symbian */
138
#if 0
139
/* There is some side-defect when SymbianPrintf is used
140
* Error in Com Port Recv
141
*/
142
extern void SymbianPrintf(void *fd, char *format, ...);
143
#define DPRINT_ERR if (defined_debug & DEBUG_ERR) \
144
SymbianPrintf
145
#define DPRINT_INFO if (defined_debug & DEBUG_INFO) \
146
SymbianPrintf
147
#define DPRINT_DBG if (defined_debug & DEBUG_DBG) \
148
SymbianPrintf
149
#else
150
#define DPRINT_ERR if (defined_debug & DEBUG_ERR) \
151
fprintf
152
#define DPRINT_INFO if (defined_debug & DEBUG_INFO) \
153
fprintf
154
#define DPRINT_DBG if (defined_debug & DEBUG_DBG) \
155
fprintf
156
#endif /* TARGETOS_symbian */
157
extern unsigned short defined_debug;
158
#ifdef WIN32
159
#if 0
160
#define IPV4_ADDR_LEN 4
161
/* IPV4 packet formats */
162
struct ipv4_addr {
163
uint8 addr[IPV4_ADDR_LEN];
164
} PACKED;
165
#endif
166
/* Function defined in wlu.c for client and wlu_server_ce.c for server */
167
extern int wl_atoip(const char *a, struct ipv4_addr *n);
168
#endif /* WIN32 */
169
/* Function defined to do host to network and network to host conversions */
170
void rwl_swap_header(rem_ioctl_t *rem_ptr, bool host_to_network);
171
172
/* Macros to access remote type */
173
extern int remote_type;
174
#define rwl_get_remote_type() (remote_type)
175
#define rwl_set_remote_type(type) (remote_type = type)
176
177
/* Macros to access server IP and port globals */
178
extern char *g_rwl_servIP;
179
#define rwl_get_server_ip() (g_rwl_servIP)
180
#define rwl_set_server_ip(ip) (g_rwl_servIP = ip)
181
extern unsigned short g_rwl_servport;
182
#define rwl_get_server_port() (g_rwl_servport)
183
#define rwl_set_server_port(port) (g_rwl_servport = port)
184
185
/* Wrapper functions defined in wlu_pipe_xxx.c where xxx is OS specific */
186
extern int rwl_read_serial_port(void* hndle, char* read_buf, uint data_size, uint *numread);
187
extern int rwl_write_serial_port(void* hndle, char* write_buf, unsigned long size,
188
unsigned long *numwritten);
189
extern void rwl_sleep(int delay);
190
extern void* rwl_open_transport(int remote_type, char *port, int ReadTotalTimeout, int debug);
191
extern int rwl_close_transport(int remote_type, void * handle);
192
extern int rwl_poll_serial_buffer(void *hndle);
193
extern int rwl_serial_handle_timeout(void);
194
extern void rwl_sync_delay(uint noframes);
195
196
#ifdef RWL_SOCKET
197
extern int rwl_connectsocket(int SocketDes, struct sockaddr* SerAddr, int SizeOfAddr);
198
extern int rwl_acceptconnection(int SocketDes, struct sockaddr *ClientAddr, int *SizeOfAddr);
199
extern int rwl_send_to_streamsocket(int SocketDes, const char* SendBuff, int data_size, int Flag);
200
extern int rwl_receive_from_streamsocket(int SocketDes, char* RecvBuff, int data_size, int Flag);
201
extern int rwl_init_server_socket_setup(int argc, char** argv, uint remote_type);
202
#ifdef vxworks
203
extern int rwl_GetifAddr(char *ifname, char *ifaddr);
204
#else
205
extern int rwl_GetifAddr(char *ifname, struct sockaddr_in* sa);
206
#endif /* vxworks */
207
#endif /* RWL_SOCKET */
208
209
#if defined(vxworks) || defined(LINUX)
210
extern int set_interface(void *wl, char *intf_name);
211
#endif /* defined(vxworks) || defined(LINUX) */
212
213
/* Win32 specific function wlu_pipe_win32.c */
214
extern int rwl_init_ws2_32dll(void);
215
extern int rwl_terminate_ws2_32dll(void);
216
217
/* Function definitions for wlu_client_shared.c and wlu_server_shared.c */
218
extern int rwl_var_getbuf(void *wl, const char *iovar, void *param, int param_len, void **bufptr);
219
extern int rwl_var_setbuf(void *wl, const char *iovar, void *param, int param_len);
220
extern int rwl_var_send_vs_actionframe(void* wl, const char* iovar, void* param, int param_len);
221
222
/* Function definitions for wlu_ndis.c/wlu_linux.c and wlu_server_ce.c/wlu_server_linux.c */
223
extern int wl_get(void *wl, int cmd, void *buf, int len);
224
extern int wl_set(void *wl, int cmd, void *buf, int len);
225
#ifdef RWLASD
226
typedef unsigned char BYTE;
227
extern void wfa_dut_init(BYTE **tBuf, BYTE **rBuf, BYTE **paBuf, BYTE **cBuf, struct timeval **);
228
extern int remote_asd_exec(unsigned char* command, int* cmd_len);
229
void wfa_dut_deinit(void);
230
#endif
231
extern int get_ctrlc_header(void *wl);
232
extern int remote_tx_response(void *wl, void *buf_ptr, int cmd);
233
extern rem_ioctl_t *g_rem_ptr;
234
extern int g_rwl_hndle;
235
#if defined (LINUX) || defined (MACOSX)
236
/* Variable to indiate if the server child has completed execution */
237
extern volatile sig_atomic_t g_sig_chld;
238
#endif
239
240
/*
241
* Separate paths are defined for android and linux machines
242
* / filesystem on android is read only memory
243
*/
244
#ifndef WIN32
245
#ifdef TARGETENV_android
246
#define SH_PATH "/data/busybox/sh"
247
#define SHELL_RESP_PATH "/data/local/RWL/" /* Default path for storing files for shell response */
248
#define TEMPLATE "/data/local/RWL/SyncXXXXXX"
249
#else
250
#define SHELL_RESP_PATH "/tmp/RWL/" /* Default path for storing files for shell response */
251
#define TEMPLATE "/tmp/RWL/SyncXXXXXX"
252
#define SH_PATH "/bin/sh"
253
#endif
254
#endif /* !WIN32 */
255
#endif /* _wlu_remote_h */
256
257