API Reference Manual  r8267
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 <wlp_api.h>
00051 
00052 /* Message types */
00053 #define WLP_TYPE_MGMT_REQ  0
00054 #define WLP_TYPE_MGMT_CFM  1
00055 #define WLP_TYPE_DATA_REQ  2
00056 #define WLP_TYPE_DATA_CFM  3
00057 #define WLP_TYPE_DATA_IND  4
00058 
00059 /* Message id's */
00060 #define WLP_UART_CONFIG 0
00061 #define WLP_POLL        1
00062 #define WLP_FW_VERSION  2
00063 #define WLP_FW_UPGRADE  28
00064 #define WLP_SET_MODE    22
00065 #define WLP_SET_CHANNEL 23
00066 #define WLP_RESET       24
00067 #define WLP_GET_MODE    26
00068 #define WLP_SET_PS_CONF 29
00069 #define WLP_SET_PS_ENABLE 30
00070 #define WLP_SET_CONFIG  31
00071 #define WLP_SET_LED     32
00072 #define WLP_SET_HEARTBEAT 33
00073 #define WLP_SET_POLL_PERIOD 34
00074 #define WLP_GET_CONFIG  35
00075 #define WLP_DEV_STATUS  36
00076 
00077 #define WLP_SCAN           37
00078 #define WLP_SCAN_STATUS    38
00079 #define WLP_SET_WPS        39
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 #define WLP_GET_LINKCTX    40
00085 #define WLP_SET_LINKCTX    41
00086 
00087 #define WLP_NET_STATUS     7
00088 #define WLP_NET_CONFIG     8
00089 #define WLP_NET_INFO       9
00090 #define WLP_NET_DNSLOOKUP  10
00091 #define WLP_NET_DHCPD      25
00092 
00093 #define WLP_SOCK_OPEN    11
00094 #define WLP_SOCK_BIND    12
00095 #define WLP_SOCK_LISTEN  13 
00096 #define WLP_SOCK_CONNECT 14
00097 
00098 #define WLP_SOCK_CLOSE  15
00099 #define WLP_SOCK_RECV   16
00100 #define WLP_SOCK_SEND   17
00101 #define WLP_SOCK_SENDTO 18
00102 #define WLP_SOCK_STATUS 19
00103 #define WLP_SOCK_ACCEPT 20
00104 #define WLP_SOCK_INFO   21
00105 #define WLP_SOCK_DATA   27
00106 
00107 /* Message alignment */
00108 #define WLP_SIZE_ALIGNMENT 4
00109 #define WLP_SIZE_ALIGNMENT_MASK (WLP_SIZE_ALIGNMENT - 1)
00110 #define wlp_pad(len)  \
00111         (((len) & WLP_SIZE_ALIGNMENT_MASK) ?                            \
00112          WLP_SIZE_ALIGNMENT - ((len) & WLP_SIZE_ALIGNMENT_MASK) : 0)
00113 
00114 struct wlp_uart_config_req {
00115         uint32_t baudrate;
00116         uint8_t rtscts;
00117         uint8_t pad[3];
00118 }; /* sizeof: 8 */
00119 
00120 struct wlp_set_config_req {
00121         uint8_t flags;
00122 #define WLP_FLAG_WAKEUP_PIN_PRESENT 1
00123         uint8_t pad[3];
00124 }; /* sizeof: 4 */
00125 
00126 #if WLP_STACK_OFFLOAD
00127 struct wlp_fw_upgrade_req {
00128         struct ip_addr addr;
00129         uint16_t port;
00130         uint8_t method;
00131         char pad[1];
00132 #define WLP_PATH_MAX_LENGTH 127
00133         char path[WLP_PATH_MAX_LENGTH + 1];
00134 }; /* sizeof: 136 */
00135 #endif /* WLP_STACK_OFFLOAD */
00136 
00137 struct wlp_set_mode_req {
00138         uint8_t mode;
00139         uint8_t pad[3];
00140 }; /* sizeof: 4 */
00141 
00142 struct wlp_set_channel_req {
00143         uint8_t channel;
00144         uint8_t pad[3];
00145 }; /* sizeof: 4 */
00146 
00147 struct wlp_set_ps_conf_req {
00148         uint32_t ps_delay;
00149         uint32_t traffic_timeout;
00150         uint16_t listen_interval;
00151         uint8_t ps_poll;
00152         uint8_t rx_all_dtim;
00153         char pad[3];
00154 }; /* sizeof: 24 */
00155 
00156 struct wlp_set_ps_enable_req {
00157         uint8_t enable;
00158         uint8_t pad[3];
00159 }; /* sizeof: 4 */
00160 
00161 struct wlp_set_led_req {
00162         uint8_t enable;
00163         uint8_t pad[3];
00164 }; /* sizeof: 4 */
00165 
00166 struct wlp_set_heartbeat_req {
00167         uint32_t period;
00168 }; /* sizeof: 4 */
00169 
00170 struct wlp_set_poll_period_req {
00171         uint32_t period;
00172 }; /* sizeof: 4 */
00173 
00174 struct wlp_set_wps_req {
00175         uint8_t enable;
00176         char pad[3];
00177 }; /* sizeof: 4 */
00178 
00179 struct wlp_scan_req {
00180         struct wlp_ssid ssid;
00181         char pad[3];
00182 }; /* sizeof: 36 */
00183 
00184 struct wlp_link_up_req {
00185         struct wlp_ssid ssid;
00186         char pad[3];
00187         char key[WLP_MAX_PASS_LEN];
00188         uint8_t auth;
00189         char pad2[3];
00190 }; /* sizeof: 104 */
00191 
00192 #if WLP_STACK_OFFLOAD
00193 struct wlp_net_config_req {
00194         struct ip_addr ip;
00195         struct ip_addr netmask;
00196         struct ip_addr gw;
00197         struct ip_addr dns_server;
00198         int8_t dhcp;
00199         char pad[3];
00200 }; /* sizeof: 24 */
00201 
00202 struct wlp_net_dnslookup_req {
00203 #define WLP_HOSTNAME_MAX_LENGTH 127
00204         char host[WLP_HOSTNAME_MAX_LENGTH + 1];
00205 }; /* sizeof: 128 */
00206 
00207 struct wlp_net_dhcpd_req {
00208         uint8_t enable;
00209         char pad[3];
00210 }; /* sizeof: 4 */
00211 
00212 
00213 struct wlp_sock_open_req {
00214         uint8_t stype;
00215         uint8_t protocol;
00216         char pad[2];
00217 }; /* sizeof: 4 */
00218 
00219 struct wlp_sock_bind_req {
00220         struct ip_addr ip;
00221         int16_t sockid;
00222         uint16_t port;
00223 }; /* sizeof: 8 */
00224 
00225 struct wlp_sock_listen_req {
00226         int16_t sockid;
00227         int8_t backlog;
00228         char pad[1];
00229 }; /* sizeof: 4 */
00230 
00231 struct wlp_sock_connect_req {
00232         struct ip_addr ip;
00233         int16_t sockid;
00234         uint16_t port;
00235 }; /* sizeof: 8 */
00236 
00237 struct wlp_sock_close_req {
00238         int16_t sockid;
00239         char pad[2];
00240 }; /* sizeof: 4 */
00241 
00242 struct wlp_sock_recv_req {
00243         int16_t sockid;
00244         int16_t datalen;
00245 }; /* sizeof: 4 */
00246 
00247 struct wlp_sock_send_req {
00248         int16_t sockid;
00249         int16_t datalen;
00250 }; /* sizeof: 4 */
00251 
00252 struct wlp_sock_sendto_req {
00253         struct ip_addr addr;
00254         int16_t sockid;
00255         int16_t datalen;
00256         uint16_t port;
00257         char pad[2];
00258 }; /* sizeof: 12 */
00259 
00260 struct wlp_sock_status_req {
00261         int16_t sockid;
00262         char pad[2];
00263 }; /* sizeof: 4 */
00264 
00265 struct wlp_sock_accept_req {
00266         int16_t sockid;
00267         char pad[2];
00268 }; /* sizeof: 4 */
00269 
00270 struct wlp_sock_info_req {
00271         int16_t sockid;
00272         char pad[2];
00273 }; /* sizeof: 4 */
00274 
00275 struct wlp_set_linkctx_req {
00276 #define WLP_LINKCTX_MAX_LEN        38
00277         uint8_t linkctx[WLP_LINKCTX_MAX_LEN];
00278         char pad[2];
00279 }; /* sizeof: 40 */
00280 #endif /* WLP_STACK_OFFLOAD */
00281 
00282 struct wlp_uart_config_cfm {
00283         int8_t mode; /* operation mode */
00284         char pad[3];
00285 }; /* sizeof: 4 */
00286 
00287 struct wlp_get_config_cfm {
00288         uint8_t flags;
00289         uint8_t pad[3];
00290 }; /* sizeof: 4 */
00291 
00292 struct wlp_dev_status_cfm {
00293 #define WLP_DEV_STATUS_FW_SUCCESS       (1 << 0)
00294 #define WLP_DEV_STATUS_FW_FAIL          (1 << 1)
00295         uint8_t flags;
00296         uint8_t pad[3];
00297 }; /* sizeof: 4 */
00298 
00299 struct wlp_fw_version_cfm {
00300         uint8_t major; /* WLP_VERSION(a, b, c) */
00301         uint8_t minor; /* WLP_VERSION(a, b, c) */
00302         uint8_t patch; /* WLP_VERSION(a, b, c) */
00303         char pad[1];
00304         char build[16];
00305         char hw_rev[16];
00306 }; /* sizeof: 36 */
00307 
00308 struct wlp_get_mode_cfm {
00309         uint8_t mode;
00310         char pad[3];
00311 }; /* sizeof: 4 */
00312 
00313 struct wlp_scan_status_cfm {
00314         struct wlp_network net;
00315         char pad[2];
00316 } OWL_PACKED;
00317 
00318 struct wlp_link_info_cfm {
00319         struct wlp_mac_addr hwaddr;
00320         struct wlp_mac_addr ap;
00321         struct wlp_ssid ssid;
00322         char pad[3];
00323         int16_t rssi;
00324         int16_t snr;
00325 }; /* sizeof: 52 */
00326 
00327 #if WLP_STACK_OFFLOAD
00328 struct wlp_net_info_cfm {
00329         struct ip_addr ip;
00330         struct ip_addr netmask;
00331         struct ip_addr gw;
00332         struct ip_addr dns_server;
00333         struct ip_addr dns_lookup;
00334 
00335 #define WLP_LINKCTX_MAX_LEN        38
00336         uint16_t linkctx_len;
00337         uint8_t linkctx[WLP_LINKCTX_MAX_LEN];
00338 
00339 #define WLP_DNS_OK       0
00340 #define WLP_DNS_ERROR   -1
00341 #define WLP_DNS_AGAIN   -2
00342 #define WLP_DNS_INVALID -3
00343         int8_t dns_result;
00344         int8_t dhcp;
00345         char pad[2];
00346 }; /* sizeof: 64 */
00347 
00348 struct wlp_sock_status_cfm {
00349 #define WLP_SOCK_STATE_DISCONNECTED 0 /* default */
00350 #define WLP_SOCK_STATE_CONNECTED 1
00351 #define WLP_SOCK_STATE_LISTEN 2
00352 #define WLP_SOCK_STATE_ACCEPT 3
00353 #define WLP_SOCK_STATE_ERROR 4
00354         int8_t state;
00355         char pad[3];
00356 }; /* sizeof: 4 */
00357 
00358 struct wlp_sock_info_cfm {
00359         struct ip_addr peer;
00360 }; /* sizeof: 4 */
00361 #endif /* WLP_STACK_OFFLOAD */
00362 
00363 struct wlp_hdr {
00364         uint16_t len;
00365         uint8_t type;
00366         uint8_t id;
00367         int16_t res;
00368         uint8_t pad;
00369         char reserved[1];
00370 };
00371 
00372 struct wlp_req {
00373         union {
00374                 struct wlp_uart_config_req uart_config;
00375                 struct wlp_set_config_req config;
00376 #if WLP_STACK_OFFLOAD
00377                 struct wlp_fw_upgrade_req fw_upgrade;
00378 #endif
00379                 struct wlp_set_mode_req set_mode;
00380                 struct wlp_set_channel_req set_channel;
00381                 struct wlp_set_ps_conf_req ps_config;
00382                 struct wlp_set_ps_enable_req ps_enable;
00383                 struct wlp_set_led_req led_enable;
00384                 struct wlp_set_heartbeat_req heartbeat;
00385                 struct wlp_set_poll_period_req poll_period;
00386                 
00387                 struct wlp_link_up_req link_up;
00388                 struct wlp_scan_req scan;
00389                 struct wlp_set_wps_req wps;
00390 #if WLP_STACK_OFFLOAD
00391                 struct wlp_net_config_req net_config;
00392                 struct wlp_net_dnslookup_req net_dnslookup;
00393                 struct wlp_net_dhcpd_req net_dhcpd;
00394 
00395                 struct wlp_sock_open_req sock_open;
00396                 struct wlp_sock_bind_req sock_bind;
00397                 struct wlp_sock_listen_req sock_listen;
00398                 struct wlp_sock_connect_req sock_connect;
00399                 struct wlp_sock_close_req sock_close;
00400                 struct wlp_sock_recv_req sock_recv;
00401                 struct wlp_sock_send_req sock_send;
00402                 struct wlp_sock_sendto_req sock_sendto;
00403                 struct wlp_sock_status_req sock_status;
00404                 struct wlp_sock_accept_req sock_accept;
00405                 struct wlp_sock_info_req sock_info;
00406                 
00407                 struct wlp_set_linkctx_req set_linkctx;
00408 #endif
00409         } u; /* C89 */
00410 };
00411 
00412 struct wlp_cfm {
00413         union {
00414                 struct wlp_uart_config_cfm uart_config;
00415                 struct wlp_get_config_cfm fw_config;
00416                 struct wlp_dev_status_cfm dev_status;
00417                 struct wlp_fw_version_cfm fw_version;
00418                 struct wlp_get_mode_cfm get_mode;
00419                 
00420                 struct wlp_scan_status_cfm scan_status;
00421                 struct wlp_link_info_cfm link_info;
00422                 
00423 #if WLP_STACK_OFFLOAD
00424                 struct wlp_net_info_cfm net_info;
00425 
00426                 struct wlp_sock_status_cfm sock_status;
00427                 struct wlp_sock_info_cfm sock_info;
00428 #endif
00429         } u; /* C89 */
00430 };
00431 
00432 struct wlp_msg {
00433         struct wlp_hdr hdr;
00434         union {
00435                 struct wlp_req req;
00436                 struct wlp_cfm cfm;
00437                 char payload[1];
00438         } u; /* C89 */
00439 };
00440 
00441 #endif /* WLP_PROTO_H */