• Main Page
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

wlp_proto.h

00001 /*
00002  * Copyright (C) 2012, H&D Wireless AB All rights reserved.
00003  *
00004  * The license to use this software in whole and in part and to
00005  * redistribute it in any form follows with the WiFi HW module from H&D
00006  * Wireless and is granted under the following restrictions:
00007  * 
00008  * 1. Redistributions of source code must retain the above copyright
00009  *    notice, this list of conditions and the following disclaimer.
00010  *
00011  * 2. Redistributions in binary form must reproduce the above copyright
00012  *    notice, this list of conditions and the following disclaimer in the
00013  *    documentation and/or other materials provided with the distribution.
00014  *
00015  * 3. The name of H&D Wireless AB may not be used to endorse or promote
00016  *    products derived from this software without specific prior written
00017  *    permission.
00018  *
00019  * 4. The software may only be used together with hardware from H&D
00020  *    Wireless all other use is prohibited.
00021  *
00022  * 5. The license to use and redistribute the software is granted
00023  *    together with the purchase of a hardware platform on a one to one
00024  *    basis.
00025  *
00026  * 6. The binary code may not be reversed engineered or by other means
00027  *    copied to circumvent this license.
00028  * 
00029  * THIS SOFTWARE IS PROVIDED BY H&D WIRELESS AB ``AS IS'' AND ANY
00030  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00031  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00032  * PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT
00033  * SHALL HD WIRELESS AB BE LIABLE FOR ANY DIRECT, INDIRECT,
00034  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
00035  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
00036  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00037  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
00038  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00039  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
00040  * OF THE POSSIBILITY OF SUCH DAMAGE.
00041  *
00042  * For more information regarding this software license Contact H&D
00043  * Wireless AB (support@hd-wireless.se).
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 /* Message types */
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 /* Message id's */
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 /* WL_API_H */
00149 
00150 /* Message alignment */
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  * The struct ip_addr type is based on work from the lwIP network stack.
00162  *
00163  */
00164 
00165 /*
00166  * Copyright (c) 2001-2004 Swedish Institute of Computer Science.
00167  * All rights reserved.
00168  *
00169  * Redistribution and use in source and binary forms, with or without
00170  * modification,  are permitted provided that the following conditions are met:
00171  *
00172  * 1. Redistributions of source code must retain the above copyright notice,
00173  *    this list of conditions and the following disclaimer.
00174  * 2. Redistributions in binary form must reproduce the above copyright notice,
00175  *    this list of conditions and the following disclaimer in the documentation
00176  *    and/or other materials provided with the distribution.
00177  * 3. The name of the author may not be used to endorse or promote products
00178  *    derived from this software without specific prior written permission.
00179  *
00180  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00181  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00182  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
00183  * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00184  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00185  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
00186  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
00187  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
00188  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
00189  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
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 /* __LWIP_IP_ADDR_H__ */
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 /* !\ingroup wlp_api */
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 }; /* sizeof: 8 */
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 }; /* sizeof: 4 */
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 }; /* sizeof: 136 */
00253 #endif /* WLP_STACK_OFFLOAD */
00254 
00255 struct wlp_set_mode_req {
00256         uint8_t mode;
00257         uint8_t pad[3];
00258 }; /* sizeof: 4 */
00259 
00260 struct wlp_set_channel_req {
00261         uint8_t channel;
00262         uint8_t pad[3];
00263 }; /* sizeof: 4 */
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 }; /* sizeof: 24 */
00273 
00274 struct wlp_set_ps_enable_req {
00275         uint8_t enable;
00276         uint8_t pad[3];
00277 }; /* sizeof: 4 */
00278 
00279 struct wlp_set_led_req {
00280         uint8_t enable;
00281         uint8_t pad[3];
00282 }; /* sizeof: 4 */
00283 
00284 struct wlp_set_heartbeat_req {
00285         uint32_t period;
00286 }; /* sizeof: 4 */
00287 
00288 struct wlp_set_poll_period_req {
00289         uint32_t period;
00290 }; /* sizeof: 4 */
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 }; /* sizeof: 104 */
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 }; /* sizeof: 24 */
00309 
00310 struct wlp_net_dnslookup_req {
00311 #define WLP_HOSTNAME_MAX_LENGTH 127
00312         char host[WLP_HOSTNAME_MAX_LENGTH + 1];
00313 }; /* sizeof: 128 */
00314 
00315 struct wlp_net_dhcpd_req {
00316         uint8_t enable;
00317         char pad[3];
00318 }; /* sizeof: 4 */
00319 
00320 
00321 struct wlp_sock_open_req {
00322         uint8_t stype;
00323         uint8_t protocol;
00324         char pad[2];
00325 }; /* sizeof: 4 */
00326 
00327 struct wlp_sock_bind_req {
00328         struct ip_addr ip;
00329         int16_t sockid;
00330         uint16_t port;
00331 }; /* sizeof: 8 */
00332 
00333 struct wlp_sock_listen_req {
00334         int16_t sockid;
00335         int8_t backlog;
00336         char pad[1];
00337 }; /* sizeof: 4 */
00338 
00339 struct wlp_sock_connect_req {
00340         struct ip_addr ip;
00341         int16_t sockid;
00342         uint16_t port;
00343 }; /* sizeof: 8 */
00344 
00345 struct wlp_sock_close_req {
00346         int16_t sockid;
00347         char pad[2];
00348 }; /* sizeof: 4 */
00349 
00350 struct wlp_sock_recv_req {
00351         int16_t sockid;
00352         int16_t datalen;
00353 }; /* sizeof: 4 */
00354 
00355 struct wlp_sock_send_req {
00356         int16_t sockid;
00357         int16_t datalen;
00358 }; /* sizeof: 4 */
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 }; /* sizeof: 12 */
00367 
00368 struct wlp_sock_status_req {
00369         int16_t sockid;
00370         char pad[2];
00371 }; /* sizeof: 4 */
00372 
00373 struct wlp_sock_accept_req {
00374         int16_t sockid;
00375         char pad[2];
00376 }; /* sizeof: 4 */
00377 
00378 struct wlp_sock_info_req {
00379         int16_t sockid;
00380         char pad[2];
00381 }; /* sizeof: 4 */
00382 #endif /* WLP_STACK_OFFLOAD */
00383 
00384 struct wlp_uart_config_cfm {
00385         int8_t mode; /* operation mode */
00386         char pad[3];
00387 }; /* sizeof: 4 */
00388 
00389 struct wlp_get_config_cfm {
00390         uint8_t flags;
00391         uint8_t pad[3];
00392 }; /* sizeof: 4 */
00393 
00394 struct wlp_fw_version_cfm {
00395         uint8_t major; /* WLP_VERSION(a, b, c) */
00396         uint8_t minor; /* WLP_VERSION(a, b, c) */
00397         uint8_t patch; /* WLP_VERSION(a, b, c) */
00398         char pad[1];
00399         char build[16];
00400         char hw_rev[16];
00401 }; /* sizeof: 36 */
00402 
00403 struct wlp_get_mode_cfm {
00404         uint8_t mode;
00405         char pad[3];
00406 }; /* sizeof: 4 */
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 }; /* sizeof: 52 */
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 }; /* sizeof: 24 */
00433 
00434 struct wlp_sock_status_cfm {
00435 #define WLP_SOCK_STATE_DISCONNECTED 0 /* default */
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 }; /* sizeof: 4 */
00443 
00444 struct wlp_sock_info_cfm {
00445         struct ip_addr peer;
00446 }; /* sizeof: 4 */
00447 #endif /* WLP_STACK_OFFLOAD */
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 /* API version */
00522 #define WLP_VERSION_CODE WLP_VERSION(1,3,1)
00523 
00524 #endif /* WLP_PROTO_H */

Generated on Fri Jul 6 2012 16:56:25 for API Reference Manual by  doxygen 1.7.1