00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #ifndef WLP_PROTO_H
00048 #define WLP_PROTO_H
00049
00050 #include <stdint.h>
00051
00052 #if !defined(WLP_STACK_OFFLOAD)
00053 # define WLP_STACK_OFFLOAD 1
00054 #endif
00055
00056
00057 #define WLP_TYPE_MGMT_REQ 0
00058 #define WLP_TYPE_MGMT_CFM 1
00059 #define WLP_TYPE_DATA_REQ 2
00060 #define WLP_TYPE_DATA_CFM 3
00061 #define WLP_TYPE_DATA_IND 4
00062
00063
00064 #define WLP_UART_CONFIG 0
00065 #define WLP_POLL 1
00066 #define WLP_FW_VERSION 2
00067 #define WLP_FW_UPGRADE 28
00068 #define WLP_SET_MODE 22
00069 #define WLP_SET_CHANNEL 23
00070 #define WLP_RESET 24
00071 #define WLP_GET_MODE 26
00072 #define WLP_SET_PS_CONF 29
00073 #define WLP_SET_PS_ENABLE 30
00074 #define WLP_SET_CONFIG 31
00075 #define WLP_SET_LED 32
00076 #define WLP_SET_HEARTBEAT 33
00077 #define WLP_SET_POLL_PERIOD 34
00078 #define WLP_GET_CONFIG 35
00079
00080 #define WLP_LINK_UP 3
00081 #define WLP_LINK_DOWN 4
00082 #define WLP_LINK_STATUS 5
00083 #define WLP_LINK_INFO 6
00084
00085 #define WLP_NET_STATUS 7
00086 #define WLP_NET_CONFIG 8
00087 #define WLP_NET_INFO 9
00088 #define WLP_NET_DNSLOOKUP 10
00089 #define WLP_NET_DHCPD 25
00090
00091 #define WLP_SOCK_OPEN 11
00092 #define WLP_SOCK_BIND 12
00093 #define WLP_SOCK_LISTEN 13
00094 #define WLP_SOCK_CONNECT 14
00095
00096 #define WLP_SOCK_CLOSE 15
00097 #define WLP_SOCK_RECV 16
00098 #define WLP_SOCK_SEND 17
00099 #define WLP_SOCK_SENDTO 18
00100 #define WLP_SOCK_STATUS 19
00101 #define WLP_SOCK_ACCEPT 20
00102 #define WLP_SOCK_INFO 21
00103 #define WLP_SOCK_DATA 27
00104
00106 enum wlp_auth_mode {
00107 WLP_AUTH_AUTO = 0,
00108 WLP_AUTH_WEP,
00109 WLP_AUTH_WPA_PSK,
00110 WLP_AUTH_WPA2_PSK,
00111 WLP_AUTH_WPA,
00112 WLP_AUTH_WPA2,
00113 };
00114
00115 #define WLP_SOCK_STREAM 0
00116 #define WLP_SOCK_DGRAM 1
00117 #define WLP_SOCK_RAW 2
00118
00119 enum wlp_fw_upgrade_method {
00120 WLP_UPGRADE_METHOD_HTTP_POST
00121 };
00122
00123 #ifndef WL_API_H
00124 #define WL_MAX_PASS_LEN 64
00125 #define WL_SNR_UNKNOWN -128
00126 #define WL_RSSI_UNKNOWN -128
00127 #define WL_SSID_MAX_LENGTH 32
00128 #define WL_MAC_ADDR_LENGTH 6
00129 struct wl_ssid_t {
00130 char ssid[WL_SSID_MAX_LENGTH];
00131 uint8_t len;
00132 };
00133
00134 struct wl_mac_addr_t {
00135 uint8_t octet[WL_MAC_ADDR_LENGTH];
00136 };
00137
00138 #define WL_MODE_STA 0
00139 #define WL_MODE_AP 1
00140 #define WL_MODE_ADHOC 2
00141 #define WL_MODE_WPS 3
00142
00143 enum wl_conn_type_t {
00144 WL_CONN_TYPE_INFRA,
00145 WL_CONN_TYPE_ADHOC
00146 };
00147
00148 #endif
00149
00150
00151 #define WLP_SIZE_ALIGNMENT 4
00152 #define WLP_SIZE_ALIGNMENT_MASK (WLP_SIZE_ALIGNMENT - 1)
00153 #define wlp_pad(len) \
00154 (((len) & WLP_SIZE_ALIGNMENT_MASK) ? \
00155 WLP_SIZE_ALIGNMENT - ((len) & WLP_SIZE_ALIGNMENT_MASK) : 0)
00156
00157
00158 #if !defined(__LWIP_IP_ADDR_H__) && !defined(__LWIPOPTS_H__)
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192 struct ip_addr {
00193 uint32_t addr;
00194 };
00195
00196 extern const struct ip_addr ip_addr_any;
00197
00198 #define IP_ADDR_ANY ((struct ip_addr *) &ip_addr_any)
00199 #define IP4_ADDR(ipaddr, a,b,c,d) \
00200 (ipaddr)->addr = htonl(((uint32_t)((a) & 0xff) << 24) | \
00201 ((uint32_t)((b) & 0xff) << 16) | \
00202 ((uint32_t)((c) & 0xff) << 8) | \
00203 (uint32_t)((d) & 0xff))
00204 #define ip_addr_set(dest, src) \
00205 (dest)->addr = ((src) == NULL? 0: (src)->addr)
00206 #define ip_addr_netcmp(addr1, addr2, mask) \
00207 (((addr1)->addr & (mask)->addr) == ((addr2)->addr & (mask)->addr))
00208 #define ip_addr_cmp(addr1, addr2) \
00209 ((addr1)->addr == (addr2)->addr)
00210 #define ip_addr_isany(addr1) \
00211 ((addr1) == NULL || (addr1)->addr == 0)
00212
00213 #define ip4_addr1(ipaddr) ((uint16_t)(ntohl((ipaddr)->addr) >> 24) & 0xff)
00214 #define ip4_addr2(ipaddr) ((uint16_t)(ntohl((ipaddr)->addr) >> 16) & 0xff)
00215 #define ip4_addr3(ipaddr) ((uint16_t)(ntohl((ipaddr)->addr) >> 8) & 0xff)
00216 #define ip4_addr4(ipaddr) ((uint16_t)(ntohl((ipaddr)->addr)) & 0xff)
00217
00218 #endif
00219
00220 #define WLP_VERSION(a,b,c) (((uint32_t)((a) & 0xff) << 16) | \
00221 ((uint32_t)((b) & 0xff) << 8) | \
00222 (uint32_t)((c) & 0xff))
00223 #define WLP_MAJOR_VERSION(code) ((uint16_t)((code) >> 16) & 0xff)
00224 #define WLP_MINOR_VERSION(code) ((uint16_t)((code) >> 8) & 0xff)
00225 #define WLP_PATCH_VERSION(code) ((uint16_t)((code)) & 0xff)
00226
00227
00228
00229 #define WLP_CAP_HA_PIN (1 << 0)
00230 #define WLP_CAP_WAKEUP_PIN (1 << 1)
00232 struct wlp_uart_config_req {
00233 uint32_t baudrate;
00234 uint8_t rtscts;
00235 uint8_t pad[3];
00236 };
00237
00238 struct wlp_set_config_req {
00239 uint8_t flags;
00240 #define WLP_FLAG_WAKEUP_PIN_PRESENT 1
00241 uint8_t pad[3];
00242 };
00243
00244 #if WLP_STACK_OFFLOAD
00245 struct wlp_fw_upgrade_req {
00246 struct ip_addr addr;
00247 uint16_t port;
00248 uint8_t method;
00249 char pad[1];
00250 #define WLP_PATH_MAX_LENGTH 127
00251 char path[WLP_PATH_MAX_LENGTH + 1];
00252 };
00253 #endif
00254
00255 struct wlp_set_mode_req {
00256 uint8_t mode;
00257 uint8_t pad[3];
00258 };
00259
00260 struct wlp_set_channel_req {
00261 uint8_t channel;
00262 uint8_t pad[3];
00263 };
00264
00265 struct wlp_set_ps_conf_req {
00266 uint32_t ps_delay;
00267 uint32_t traffic_timeout;
00268 uint16_t listen_interval;
00269 uint8_t ps_poll;
00270 uint8_t rx_all_dtim;
00271 char pad[3];
00272 };
00273
00274 struct wlp_set_ps_enable_req {
00275 uint8_t enable;
00276 uint8_t pad[3];
00277 };
00278
00279 struct wlp_set_led_req {
00280 uint8_t enable;
00281 uint8_t pad[3];
00282 };
00283
00284 struct wlp_set_heartbeat_req {
00285 uint32_t period;
00286 };
00287
00288 struct wlp_set_poll_period_req {
00289 uint32_t period;
00290 };
00291
00292 struct wlp_link_up_req {
00293 struct wl_ssid_t ssid;
00294 char pad[3];
00295 char key[WL_MAX_PASS_LEN];
00296 uint8_t auth;
00297 char pad2[3];
00298 };
00299
00300 #if WLP_STACK_OFFLOAD
00301 struct wlp_net_config_req {
00302 struct ip_addr ip;
00303 struct ip_addr netmask;
00304 struct ip_addr gw;
00305 struct ip_addr dns_server;
00306 int8_t dhcp;
00307 char pad[3];
00308 };
00309
00310 struct wlp_net_dnslookup_req {
00311 #define WLP_HOSTNAME_MAX_LENGTH 127
00312 char host[WLP_HOSTNAME_MAX_LENGTH + 1];
00313 };
00314
00315 struct wlp_net_dhcpd_req {
00316 uint8_t enable;
00317 char pad[3];
00318 };
00319
00320
00321 struct wlp_sock_open_req {
00322 uint8_t stype;
00323 uint8_t protocol;
00324 char pad[2];
00325 };
00326
00327 struct wlp_sock_bind_req {
00328 struct ip_addr ip;
00329 int16_t sockid;
00330 uint16_t port;
00331 };
00332
00333 struct wlp_sock_listen_req {
00334 int16_t sockid;
00335 int8_t backlog;
00336 char pad[1];
00337 };
00338
00339 struct wlp_sock_connect_req {
00340 struct ip_addr ip;
00341 int16_t sockid;
00342 uint16_t port;
00343 };
00344
00345 struct wlp_sock_close_req {
00346 int16_t sockid;
00347 char pad[2];
00348 };
00349
00350 struct wlp_sock_recv_req {
00351 int16_t sockid;
00352 int16_t datalen;
00353 };
00354
00355 struct wlp_sock_send_req {
00356 int16_t sockid;
00357 int16_t datalen;
00358 };
00359
00360 struct wlp_sock_sendto_req {
00361 struct ip_addr addr;
00362 int16_t sockid;
00363 int16_t datalen;
00364 uint16_t port;
00365 char pad[2];
00366 };
00367
00368 struct wlp_sock_status_req {
00369 int16_t sockid;
00370 char pad[2];
00371 };
00372
00373 struct wlp_sock_accept_req {
00374 int16_t sockid;
00375 char pad[2];
00376 };
00377
00378 struct wlp_sock_info_req {
00379 int16_t sockid;
00380 char pad[2];
00381 };
00382 #endif
00383
00384 struct wlp_uart_config_cfm {
00385 int8_t mode;
00386 char pad[3];
00387 };
00388
00389 struct wlp_get_config_cfm {
00390 uint8_t flags;
00391 uint8_t pad[3];
00392 };
00393
00394 struct wlp_fw_version_cfm {
00395 uint8_t major;
00396 uint8_t minor;
00397 uint8_t patch;
00398 char pad[1];
00399 char build[16];
00400 char hw_rev[16];
00401 };
00402
00403 struct wlp_get_mode_cfm {
00404 uint8_t mode;
00405 char pad[3];
00406 };
00407
00408 struct wlp_link_info_cfm {
00409 struct wl_mac_addr_t hwaddr;
00410 struct wl_mac_addr_t ap;
00411 struct wl_ssid_t ssid;
00412 char pad[3];
00413 int16_t rssi;
00414 int16_t snr;
00415 };
00416
00417 #if WLP_STACK_OFFLOAD
00418 struct wlp_net_info_cfm {
00419 struct ip_addr ip;
00420 struct ip_addr netmask;
00421 struct ip_addr gw;
00422 struct ip_addr dns_server;
00423 struct ip_addr dns_lookup;
00424
00425 #define WLP_DNS_OK 0
00426 #define WLP_DNS_ERROR -1
00427 #define WLP_DNS_AGAIN -2
00428 #define WLP_DNS_INVALID -3
00429 int8_t dns_result;
00430 int8_t dhcp;
00431 char pad[2];
00432 };
00433
00434 struct wlp_sock_status_cfm {
00435 #define WLP_SOCK_STATE_DISCONNECTED 0
00436 #define WLP_SOCK_STATE_CONNECTED 1
00437 #define WLP_SOCK_STATE_LISTEN 2
00438 #define WLP_SOCK_STATE_ACCEPT 3
00439 #define WLP_SOCK_STATE_ERROR 4
00440 int8_t state;
00441 char pad[3];
00442 };
00443
00444 struct wlp_sock_info_cfm {
00445 struct ip_addr peer;
00446 };
00447 #endif
00448
00449 struct wlp_hdr {
00450 uint16_t len;
00451 uint8_t type;
00452 uint8_t id;
00453 int16_t res;
00454 uint8_t pad;
00455 char reserved[1];
00456 };
00457
00458 struct wlp_req {
00459 union {
00460 struct wlp_uart_config_req uart_config;
00461 struct wlp_set_config_req config;
00462 #if WLP_STACK_OFFLOAD
00463 struct wlp_fw_upgrade_req fw_upgrade;
00464 #endif
00465 struct wlp_set_mode_req set_mode;
00466 struct wlp_set_channel_req set_channel;
00467 struct wlp_set_ps_conf_req ps_config;
00468 struct wlp_set_ps_enable_req ps_enable;
00469 struct wlp_set_led_req led_enable;
00470 struct wlp_set_heartbeat_req heartbeat;
00471 struct wlp_set_poll_period_req poll_period;
00472
00473 struct wlp_link_up_req link_up;
00474 #if WLP_STACK_OFFLOAD
00475 struct wlp_net_config_req net_config;
00476 struct wlp_net_dnslookup_req net_dnslookup;
00477 struct wlp_net_dhcpd_req net_dhcpd;
00478
00479 struct wlp_sock_open_req sock_open;
00480 struct wlp_sock_bind_req sock_bind;
00481 struct wlp_sock_listen_req sock_listen;
00482 struct wlp_sock_connect_req sock_connect;
00483 struct wlp_sock_close_req sock_close;
00484 struct wlp_sock_recv_req sock_recv;
00485 struct wlp_sock_send_req sock_send;
00486 struct wlp_sock_sendto_req sock_sendto;
00487 struct wlp_sock_status_req sock_status;
00488 struct wlp_sock_accept_req sock_accept;
00489 struct wlp_sock_info_req sock_info;
00490 #endif
00491 };
00492 };
00493
00494 struct wlp_cfm {
00495 union {
00496 struct wlp_uart_config_cfm uart_config;
00497 struct wlp_get_config_cfm fw_config;
00498 struct wlp_fw_version_cfm fw_version;
00499 struct wlp_get_mode_cfm get_mode;
00500
00501 struct wlp_link_info_cfm link_info;
00502
00503 #if WLP_STACK_OFFLOAD
00504 struct wlp_net_info_cfm net_info;
00505
00506 struct wlp_sock_status_cfm sock_status;
00507 struct wlp_sock_info_cfm sock_info;
00508 #endif
00509 };
00510 };
00511
00512 struct wlp_msg {
00513 struct wlp_hdr hdr;
00514 union {
00515 struct wlp_req req;
00516 struct wlp_cfm cfm;
00517 char payload[1];
00518 };
00519 };
00520
00521
00522 #define WLP_VERSION_CODE WLP_VERSION(1,3,1)
00523
00524 #endif