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