DeepCover Embedded Security in IoT: Public-key Secured Data Paths

Dependencies:   MaximInterface

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers simplelink.h Source File

simplelink.h

00001 /*
00002  * simplelink.h - CC31xx/CC32xx Host Driver Implementation
00003  *
00004  * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/ 
00005  * 
00006  * 
00007  *  Redistribution and use in source and binary forms, with or without 
00008  *  modification, are permitted provided that the following conditions 
00009  *  are met:
00010  *
00011  *    Redistributions of source code must retain the above copyright 
00012  *    notice, this list of conditions and the following disclaimer.
00013  *
00014  *    Redistributions in binary form must reproduce the above copyright
00015  *    notice, this list of conditions and the following disclaimer in the 
00016  *    documentation and/or other materials provided with the   
00017  *    distribution.
00018  *
00019  *    Neither the name of Texas Instruments Incorporated nor the names of
00020  *    its contributors may be used to endorse or promote products derived
00021  *    from this software without specific prior written permission.
00022  *
00023  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00024  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00025  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00026  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
00027  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
00028  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00029  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00030  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00031  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00032  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00033  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00034  *
00035 */
00036 
00037 
00038 /*!
00039     \mainpage SimpleLink Driver
00040 
00041     \section intro_sec Introduction
00042 
00043  The SimpleLink CC31xx/CC2xx family allows to add Wi-Fi and networking capabilities
00044  to low-cost embedded products without having prior Wi-Fi, RF or networking expertise.
00045  The CC31xx/CC32xx is an ideal solution for microcontroller-based sensor and control
00046  applications such as home appliances, home automation and smart metering.
00047  The CC31xx/CC32xx has integrated a comprehensive TCP/IP network stack, Wi-Fi driver and
00048  security supplicant leading to easier portability to microcontrollers, to an
00049  ultra-low memory footprint, all without compromising the capabilities and robustness
00050  of the final application.
00051 
00052 
00053 
00054  \section modules_sec Module Names
00055  To make it simple, TI's SimpleLink CC31xx/CC32xx platform capabilities were divided into modules by topic (Silo). 
00056  These capabilities range from basic device management through wireless
00057  network configuration, standard BSD socket and much more.
00058  Listed below are the various modules in the SimpleLink CC31xx/CC32xx driver:
00059      -# \ref device - controls the behaviour of the CC31xx/CC32xx device (start/stop, events masking and obtaining specific device status)
00060      -# \ref wlan - controls the use of the WiFi WLAN module including:
00061        - Connection features, such as: profiles, policies, SmartConfig™
00062        - Advanced WLAN features, such as: scans, rx filters and rx statistics collection
00063      -# \ref socket - controls standard client/server sockets programming options and capabilities 
00064      -# \ref netapp - activates networking applications, such as: HTTP Server, DHCP Server, Ping, DNS and mDNS.
00065      -# \ref netcfg - controls the configuration of the device addresses (i.e. IP and MAC addresses)
00066      -# \ref FileSystem     - provides file system capabilities to TI's CC31XX that can be used by both the CC31XX device and the user.
00067 
00068 
00069  \section         proting_sec     Porting Guide
00070 
00071  The porting of the SimpleLink driver to any new platform is based on few simple steps.
00072  This guide takes you through this process step by step. Please follow the instructions
00073  carefully to avoid any problems during this process and to enable efficient and proper
00074  work with the device.
00075  Please notice that all modifications and porting adjustments of the driver should be
00076  made in the user.h header file only.
00077  Keep making any of the changes only in this file will ensure smoothly transaction to
00078  new versions of the driver at the future!
00079 
00080 
00081  \subsection     porting_step1   Step 1 - Create your own user.h file
00082 
00083  The first step is to create a user.h file that will include your configurations and
00084  adjustments. You can use the empty template provided as part of this driver or
00085  you can choose to base your file on file from one of the wide range of examples
00086  applications provided by Texas Instruments
00087 
00088 
00089  \subsection    porting_step2   Step 2 - Select the capabilities set required for your application
00090 
00091  Texas Instruments made a lot of efforts to build set of predefined capability sets that would
00092  fit most of the target application.
00093  It is recommended to try and choose one of this predefined capabilities set before going to
00094  build your own customized set. If you find compatible set you can skip the rest of this step.
00095 
00096  The available sets are:
00097      -# SL_TINY     -   Compatible to be used on platforms with very limited resources. Provides
00098                         the best in class foot print in terms of Code and Data consumption.
00099      -# SL_SMALL    -   Compatible to most common networking applications. Provide the most
00100                         common APIs with decent balance between code size, data size, functionality
00101                         and performances
00102      -# SL_FULL     -   Provide access to all SimpleLink functionalities
00103 
00104 
00105  \subsection    porting_step3   Step 3 - Bind the device enable/disable output line
00106 
00107  The enable/disable line (nHib) provide mechanism to enter the device into the least current
00108  consumption mode. This mode could be used when no traffic is required (tx/rx).
00109  when this line is not connected to any IO of the host this define should be left empty.
00110  Not connecting this line results in ability to start the driver only once.
00111 
00112 
00113  \subsection    porting_step4   Step 4 - Writing your interface communication driver
00114 
00115  The SimpleLink device support several standard communication protocol among SPI and
00116  UART. Depending on your needs and your hardware design, you should choose the
00117  communication channel type.
00118  The interface for this communication channel should include 4 simple access functions:
00119  -# open
00120  -# close
00121  -# read
00122  -# write
00123 
00124  The way this driver would be implemented is directly effecting the efficiency and
00125  the performances of the SimpleLink device on this platform.
00126  If your system has DMA you should consider to use it in order to increase the utilization
00127  of the communication channel
00128  If you have enough memory resources you should consider using a buffer to increase the
00129  efficiency of the write operations.
00130 
00131 
00132  \subsection     porting_step5   Step 5 - Choose your memory management model
00133 
00134  The SimpleLink driver support two memory models:
00135      -# Static (default)
00136      -# Dynamic
00137 
00138  If you choose to work in dynamic model you will have to provide alloc and free functions
00139  to be used by the Simple Link driver otherwise nothing need to be done.
00140 
00141 
00142  \subsection     porting_step6   Step 6 - OS adaptation
00143 
00144  The SimpleLink driver could run on two kind of platforms:
00145      -# Non-Os / Single Threaded (default)
00146      -# Multi-Threaded
00147 
00148  If you choose to work in multi-threaded environment under operating system you will have to
00149  provide some basic adaptation routines to allow the driver to protect access to resources
00150  for different threads (locking object) and to allow synchronization between threads (sync objects).
00151  In additional the driver support running without dedicated thread allocated solely to the simple
00152  link driver. If you choose to work in this mode, you should also supply a spawn method that
00153  will enable to run function on a temporary context.
00154 
00155 
00156  \subsection     porting_step7   Step 7 - Set your asynchronous event handlers routines
00157 
00158  The SimpleLink device generate asynchronous events in several situations.
00159  These asynchronous events could be masked.
00160  In order to catch these events you have to provide handler routines.
00161  Please notice that if you not provide a handler routine and the event is received,
00162  the driver will drop this event without any indication of this drop.
00163 
00164 
00165  \subsection     porting_step8   Step 8 - Run diagnostic tools to validate the correctness of your porting
00166 
00167  The driver is delivered with some porting diagnostic tools to simplify the porting validation process
00168  and to reduce issues latter. It is very important to follow carefully this process.
00169 
00170  The diagnostic process include:
00171      -# Validating Interface Communication Driver
00172      -# Validating OS adaptation layer
00173      -# Validating HW integrity
00174      -# Validating basic work with the device
00175 
00176 
00177     \section sw_license License
00178 
00179  *
00180  *
00181  * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/ 
00182  * 
00183  * 
00184  *  Redistribution and use in source and binary forms, with or without 
00185  *  modification, are permitted provided that the following conditions 
00186  *  are met:
00187  *
00188  *    Redistributions of source code must retain the above copyright 
00189  *    notice, this list of conditions and the following disclaimer.
00190  *
00191  *    Redistributions in binary form must reproduce the above copyright
00192  *    notice, this list of conditions and the following disclaimer in the 
00193  *    documentation and/or other materials provided with the   
00194  *    distribution.
00195  *
00196  *    Neither the name of Texas Instruments Incorporated nor the names of
00197  *    its contributors may be used to endorse or promote products derived
00198  *    from this software without specific prior written permission.
00199  *
00200  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
00201  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
00202  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00203  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
00204  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
00205  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
00206  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00207  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00208  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
00209  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
00210  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00211  *
00212 */
00213     
00214     
00215 
00216 #ifndef __SIMPLELINK_H__
00217 #define    __SIMPLELINK_H__
00218 
00219 /* define the default types
00220  * If user wants to overwrite it,
00221  * he need to undef and define again */
00222 #define _u8  unsigned char
00223 #define _i8  signed char
00224 #define _u16 unsigned short
00225 #define _i16 signed short
00226 #define _u32 unsigned long
00227 #define _i32 signed long
00228 
00229 #define _volatile volatile
00230 #define _const    const
00231 
00232 #include "user.h"
00233 
00234 #ifdef    __cplusplus
00235 extern "C"
00236 {
00237 #endif
00238 
00239 
00240 /*! \attention  Async event activation notes
00241     Function prototypes for event callback handlers                               
00242     Event handler function names should be defined in the user.h file             
00243     e.g.                                                                          
00244     "#define sl_WlanEvtHdlr   SLWlanEventHandler"                               
00245     Indicates all WLAN events are handled by User func "SLWlanEventHandler"                                                                       
00246     Important notes:                                                              
00247     1. Event handlers cannot activate another SimpleLink API from the event's context                                                                    
00248     2. Event's data is valid during event's context. Any application data         
00249        which is required for the user application should be copied or marked      
00250        into user's variables                                                      
00251     3. It is not recommended to delay the execution of the event callback handler 
00252 
00253 */
00254 
00255 /*!
00256 
00257     \addtogroup UserEvents
00258     @{
00259 
00260 */
00261 
00262 
00263 /*****************************************************************************/
00264 /* Macro declarations for Host Driver version                                */
00265 /*****************************************************************************/
00266 #define SL_DRIVER_VERSION   "1.0.1.6"
00267 #define SL_MAJOR_VERSION_NUM    1L
00268 #define SL_MINOR_VERSION_NUM    0L
00269 #define SL_VERSION_NUM          1L
00270 #define SL_SUB_VERSION_NUM      6L
00271 
00272 
00273 /*****************************************************************************/
00274 /* Macro declarations for predefined configurations                          */
00275 /*****************************************************************************/
00276 
00277 #ifdef SL_TINY
00278 
00279 #undef SL_INC_ARG_CHECK
00280 #undef SL_INC_EXT_API
00281 #undef SL_INC_SOCK_SERVER_SIDE_API
00282 #undef SL_INC_WLAN_PKG
00283 #undef SL_INC_NET_CFG_PKG
00284 #undef SL_INC_FS_PKG
00285 #undef SL_INC_SET_UART_MODE
00286 #undef SL_INC_NVMEM_PKG
00287 #define SL_INC_STD_BSD_API_NAMING
00288 #define SL_INC_SOCK_CLIENT_SIDE_API
00289 #define SL_INC_SOCK_RECV_API
00290 #define SL_INC_SOCK_SEND_API
00291 #define SL_INC_SOCKET_PKG
00292 #define SL_INC_NET_APP_PKG
00293 
00294 #endif
00295 
00296 #ifdef SL_SMALL
00297 #undef SL_INC_EXT_API
00298 #undef SL_INC_NET_APP_PKG
00299 #undef SL_INC_NET_CFG_PKG
00300 #undef SL_INC_FS_PKG
00301 #define SL_INC_ARG_CHECK
00302 #define SL_INC_WLAN_PKG
00303 #define SL_INC_SOCKET_PKG
00304 #define SL_INC_SOCK_CLIENT_SIDE_API
00305 #define SL_INC_SOCK_SERVER_SIDE_API
00306 #define SL_INC_SOCK_RECV_API
00307 #define SL_INC_SOCK_SEND_API
00308 #define SL_INC_SET_UART_MODE
00309 #endif
00310 
00311 #ifdef SL_FULL
00312 #define SL_INC_EXT_API
00313 #define SL_INC_NET_APP_PKG
00314 #define SL_INC_NET_CFG_PKG
00315 #define SL_INC_FS_PKG
00316 #define SL_INC_ARG_CHECK
00317 #define SL_INC_WLAN_PKG
00318 #define SL_INC_SOCKET_PKG
00319 #define SL_INC_SOCK_CLIENT_SIDE_API
00320 #define SL_INC_SOCK_SERVER_SIDE_API
00321 #define SL_INC_SOCK_RECV_API
00322 #define SL_INC_SOCK_SEND_API
00323 #define SL_INC_SET_UART_MODE
00324 #endif
00325 
00326 #define SL_RET_CODE_OK                     (0)
00327 #define SL_RET_CODE_INVALID_INPUT          (-2)
00328 #define SL_RET_CODE_SELF_ERROR             (-3)
00329 #define SL_RET_CODE_NWP_IF_ERROR           (-4)
00330 #define SL_RET_CODE_MALLOC_ERROR           (-5)
00331 #define SL_RET_CODE_ABORT                  (-6)
00332 #define SL_RET_CODE_PROTOCOL_ERROR         (-7)  
00333 
00334 
00335 /* #define sl_Memcpy       memcpy */
00336 #define sl_Memset(addr, val, len)      memset(addr, val, (size_t)len)
00337 #define sl_Memcpy(dest, src, len)      memcpy(dest, src, (size_t)len)
00338   
00339 #ifndef SL_TINY_EXT
00340 #define SL_MAX_SOCKETS      (_u8)(8)
00341 #else
00342 #define SL_MAX_SOCKETS      (_u8)(2)
00343 #endif
00344 
00345   
00346 /*****************************************************************************/
00347 /* Types definitions                                                                                                                */
00348 /*****************************************************************************/  
00349 
00350 #ifndef NULL
00351 #define NULL        (0)
00352 #endif
00353 
00354 #ifndef FALSE
00355 #define FALSE       (0)
00356 #endif
00357 
00358 #ifndef TRUE
00359 #define TRUE        (!FALSE)
00360 #endif
00361 
00362 #ifndef OK
00363 #define OK          (0)
00364 #endif
00365 
00366 typedef _u16  _SlOpcode_t;
00367 typedef _u8   _SlArgSize_t;
00368 typedef _i16   _SlDataSize_t;
00369 typedef _i16   _SlReturnVal_t;
00370 
00371 
00372 
00373 /*
00374  * This event status used to  block or continue the event propagation
00375  * through all the registered external libs/user application
00376  *
00377  */
00378 
00379  typedef enum {
00380     EVENT_PROPAGATION_BLOCK = 0,
00381     EVENT_PROPAGATION_CONTINUE
00382 
00383  } _SlEventPropogationStatus_e;
00384 
00385 
00386 
00387 
00388 
00389 
00390 /*****************************************************************************/
00391 /* Include files                                                             */
00392 /*****************************************************************************/
00393 
00394 
00395 /* 
00396    objInclusion.h and user.h must be included before all api header files 
00397    objInclusion.h must be the last arrangement just before including the API header files 
00398    since it based on the other configurations to decide which object should be included 
00399 */
00400 #include "../source/objInclusion.h"
00401 #include "trace.h"
00402 #include "fs.h"
00403 #include "socket.h"
00404 #include "netapp.h"
00405 #include "wlan.h"
00406 #include "device.h"
00407 #include "netcfg.h"
00408 #include "wlan_rx_filters.h"
00409 
00410 
00411  /* The general events dispatcher which is
00412   * initialized to the user handler */
00413 #ifdef sl_GeneralEvtHdlr
00414 #define _SlDrvHandleGeneralEvents sl_GeneralEvtHdlr
00415 #endif
00416 
00417  /* The wlan events dispatcher which is
00418   * initialized to the user handler */
00419 #ifdef sl_WlanEvtHdlr
00420 #define _SlDrvHandleWlanEvents sl_WlanEvtHdlr
00421 #endif
00422 
00423  /* The NetApp events dispatcher which is
00424   * initialized to the user handler */
00425 #ifdef sl_NetAppEvtHdlr
00426 #define _SlDrvHandleNetAppEvents sl_NetAppEvtHdlr
00427 #endif
00428 
00429  /* The http server events dispatcher which is
00430   * initialized to the user handler if exists */
00431 #ifdef sl_HttpServerCallback
00432 #define _SlDrvHandleHttpServerEvents sl_HttpServerCallback
00433 #endif
00434 
00435  /* The socket events dispatcher which is
00436   * initialized to the user handler */
00437 #ifdef sl_SockEvtHdlr
00438 #define _SlDrvHandleSockEvents sl_SockEvtHdlr
00439 #endif
00440 
00441 
00442 
00443 #define __CONCAT(x,y)   x ## y
00444 #define __CONCAT2(x,y)  __CONCAT(x,y)
00445 
00446 
00447 /*
00448  * The section below handles the external lib event registration
00449  * according to the desired events it specified in its API header file.
00450  * The external lib should be first installed by the user (see user.h)
00451  */
00452 #ifdef SL_EXT_LIB_1
00453 
00454     /* General Event Registration */
00455     #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_GENERAL_EVENT)
00456     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _GeneralEventHdl) (SlDeviceEvent_t *);
00457     #define SlExtLib1GeneralEventHandler   __CONCAT2(SL_EXT_LIB_1, _GeneralEventHdl)
00458 
00459     #undef EXT_LIB_REGISTERED_GENERAL_EVENTS
00460     #define EXT_LIB_REGISTERED_GENERAL_EVENTS
00461     #endif
00462 
00463     /* Wlan Event Registration */
00464     #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_WLAN_EVENT)
00465     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _WlanEventHdl) (SlWlanEvent_t *);
00466     #define SlExtLib1WlanEventHandler   __CONCAT2(SL_EXT_LIB_1, _WlanEventHdl)
00467 
00468     #undef EXT_LIB_REGISTERED_WLAN_EVENTS
00469     #define EXT_LIB_REGISTERED_WLAN_EVENTS
00470     #endif
00471 
00472     /* NetApp Event Registration */
00473     #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_NETAPP_EVENT)
00474     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _NetAppEventHdl) (SlNetAppEvent_t *);
00475     #define SlExtLib1NetAppEventHandler __CONCAT2(SL_EXT_LIB_1, _NetAppEventHdl)
00476 
00477     #undef EXT_LIB_REGISTERED_NETAPP_EVENTS
00478     #define EXT_LIB_REGISTERED_NETAPP_EVENTS
00479     #endif
00480 
00481     /* Http Server Event Registration */
00482     #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_HTTP_SERVER_EVENT)
00483     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
00484     #define SlExtLib1HttpServerEventHandler __CONCAT2(SL_EXT_LIB_1, _HttpServerEventHdl)
00485 
00486     #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
00487     #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
00488     #endif
00489 
00490     /* Socket Event Registration */
00491     #if __CONCAT2(SL_EXT_LIB_1, _NOTIFY_SOCK_EVENT)
00492     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_1, _SockEventHdl) (SlSockEvent_t *);
00493     #define SlExtLib1SockEventHandler __CONCAT2(SL_EXT_LIB_1, _SockEventHdl)
00494 
00495     #undef EXT_LIB_REGISTERED_SOCK_EVENTS
00496     #define EXT_LIB_REGISTERED_SOCK_EVENTS
00497     #endif
00498 
00499 #endif
00500 
00501 
00502 #ifdef SL_EXT_LIB_2
00503 
00504     /* General Event Registration */
00505     #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_GENERAL_EVENT)
00506     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _GeneralEventHdl) (SlDeviceEvent_t *);
00507     #define SlExtLib2GeneralEventHandler   __CONCAT2(SL_EXT_LIB_2, _GeneralEventHdl)
00508 
00509     #undef EXT_LIB_REGISTERED_GENERAL_EVENTS
00510     #define EXT_LIB_REGISTERED_GENERAL_EVENTS
00511     #endif
00512 
00513     /* Wlan Event Registration */
00514     #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_WLAN_EVENT)
00515     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _WlanEventHdl) (SlWlanEvent_t *);
00516     #define SlExtLib2WlanEventHandler   __CONCAT2(SL_EXT_LIB_2, _WlanEventHdl)
00517 
00518     #undef EXT_LIB_REGISTERED_WLAN_EVENTS
00519     #define EXT_LIB_REGISTERED_WLAN_EVENTS
00520     #endif
00521 
00522     /* NetApp Event Registration */
00523     #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_NETAPP_EVENT)
00524     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _NetAppEventHdl) (SlNetAppEvent_t *);
00525     #define SlExtLib2NetAppEventHandler __CONCAT2(SL_EXT_LIB_2, _NetAppEventHdl)
00526 
00527     #undef EXT_LIB_REGISTERED_NETAPP_EVENTS
00528     #define EXT_LIB_REGISTERED_NETAPP_EVENTS
00529     #endif
00530 
00531     /* Http Server Event Registration */
00532     #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_HTTP_SERVER_EVENT)
00533     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
00534     #define SlExtLib2HttpServerEventHandler __CONCAT2(SL_EXT_LIB_2, _HttpServerEventHdl)
00535 
00536     #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
00537     #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
00538     #endif
00539 
00540     /* Socket Event Registration */
00541     #if __CONCAT2(SL_EXT_LIB_2, _NOTIFY_SOCK_EVENT)
00542     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_2, _SockEventHdl) (SlSockEvent_t *);
00543     #define SlExtLib2SockEventHandler __CONCAT2(SL_EXT_LIB_2, _SockEventHdl)
00544 
00545     #undef EXT_LIB_REGISTERED_SOCK_EVENTS
00546     #define EXT_LIB_REGISTERED_SOCK_EVENTS
00547     #endif
00548 
00549 #endif
00550 
00551 
00552 #ifdef SL_EXT_LIB_3
00553 
00554     /* General Event Registration */
00555     #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_GENERAL_EVENT)
00556     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _GeneralEventHdl) (SlDeviceEvent_t *);
00557     #define SlExtLib3GeneralEventHandler   __CONCAT2(SL_EXT_LIB_3, _GeneralEventHdl)
00558 
00559     #undef EXT_LIB_REGISTERED_GENERAL_EVENTS
00560     #define EXT_LIB_REGISTERED_GENERAL_EVENTS
00561     #endif
00562 
00563     /* Wlan Event Registration */
00564     #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_WLAN_EVENT)
00565     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _WlanEventHdl) (SlWlanEvent_t *);
00566     #define SlExtLib3WlanEventHandler   __CONCAT2(SL_EXT_LIB_3, _WlanEventHdl)
00567 
00568     #undef EXT_LIB_REGISTERED_WLAN_EVENTS
00569     #define EXT_LIB_REGISTERED_WLAN_EVENTS
00570     #endif
00571 
00572     /* NetApp Event Registration */
00573     #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_NETAPP_EVENT)
00574     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _NetAppEventHdl) (SlNetAppEvent_t *);
00575     #define SlExtLib3NetAppEventHandler __CONCAT2(SL_EXT_LIB_3, _NetAppEventHdl)
00576 
00577     #undef EXT_LIB_REGISTERED_NETAPP_EVENTS
00578     #define EXT_LIB_REGISTERED_NETAPP_EVENTS
00579     #endif
00580 
00581     /* Http Server Event Registration */
00582     #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_HTTP_SERVER_EVENT)
00583     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
00584     #define SlExtLib3HttpServerEventHandler __CONCAT2(SL_EXT_LIB_3, _HttpServerEventHdl)
00585 
00586     #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
00587     #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
00588     #endif
00589 
00590     /* Socket Event Registration */
00591     #if __CONCAT2(SL_EXT_LIB_3, _NOTIFY_SOCK_EVENT)
00592     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_3, _SockEventHdl) (SlSockEvent_t *);
00593     #define SlExtLib3SockEventHandler __CONCAT2(SL_EXT_LIB_3, _SockEventHdl)
00594 
00595     #undef EXT_LIB_REGISTERED_SOCK_EVENTS
00596     #define EXT_LIB_REGISTERED_SOCK_EVENTS
00597     #endif
00598 
00599 #endif
00600 
00601 
00602 #ifdef SL_EXT_LIB_4
00603 
00604     /* General Event Registration */
00605     #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_GENERAL_EVENT)
00606     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _GeneralEventHdl) (SlDeviceEvent_t *);
00607     #define SlExtLib4GeneralEventHandler   __CONCAT2(SL_EXT_LIB_4, _GeneralEventHdl)
00608 
00609     #undef EXT_LIB_REGISTERED_GENERAL_EVENTS
00610     #define EXT_LIB_REGISTERED_GENERAL_EVENTS
00611     #endif
00612 
00613     /* Wlan Event Registration */
00614     #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_WLAN_EVENT)
00615     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _WlanEventHdl) (SlWlanEvent_t *);
00616     #define SlExtLib4WlanEventHandler   __CONCAT2(SL_EXT_LIB_4, _WlanEventHdl)
00617 
00618     #undef EXT_LIB_REGISTERED_WLAN_EVENTS
00619     #define EXT_LIB_REGISTERED_WLAN_EVENTS
00620     #endif
00621 
00622     /* NetApp Event Registration */
00623     #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_NETAPP_EVENT)
00624     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _NetAppEventHdl) (SlNetAppEvent_t *);
00625     #define SlExtLib4NetAppEventHandler __CONCAT2(SL_EXT_LIB_4, _NetAppEventHdl)
00626 
00627     #undef EXT_LIB_REGISTERED_NETAPP_EVENTS
00628     #define EXT_LIB_REGISTERED_NETAPP_EVENTS
00629     #endif
00630 
00631     /* Http Server Event Registration */
00632     #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_HTTP_SERVER_EVENT)
00633     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
00634     #define SlExtLib4HttpServerEventHandler __CONCAT2(SL_EXT_LIB_4, _HttpServerEventHdl)
00635 
00636     #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
00637     #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
00638     #endif
00639 
00640     /* Socket Event Registration */
00641     #if __CONCAT2(SL_EXT_LIB_4, _NOTIFY_SOCK_EVENT)
00642     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_4, _SockEventHdl) (SlSockEvent_t *);
00643     #define SlExtLib4SockEventHandler __CONCAT2(SL_EXT_LIB_4, _SockEventHdl)
00644 
00645     #undef EXT_LIB_REGISTERED_SOCK_EVENTS
00646     #define EXT_LIB_REGISTERED_SOCK_EVENTS
00647     #endif
00648 
00649 #endif
00650 
00651 
00652 #ifdef SL_EXT_LIB_5
00653 
00654     /* General Event Registration */
00655     #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_GENERAL_EVENT)
00656     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _GeneralEventHdl) (SlDeviceEvent_t *);
00657     #define SlExtLib5GeneralEventHandler   __CONCAT2(SL_EXT_LIB_5, _GeneralEventHdl)
00658 
00659     #undef EXT_LIB_REGISTERED_GENERAL_EVENTS
00660     #define EXT_LIB_REGISTERED_GENERAL_EVENTS
00661     #endif
00662 
00663     /* Wlan Event Registration */
00664     #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_WLAN_EVENT)
00665     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _WlanEventHdl) (SlWlanEvent_t *);
00666     #define SlExtLib5WlanEventHandler   __CONCAT2(SL_EXT_LIB_5, _WlanEventHdl)
00667 
00668     #undef EXT_LIB_REGISTERED_WLAN_EVENTS
00669     #define EXT_LIB_REGISTERED_WLAN_EVENTS
00670     #endif
00671 
00672     /* NetApp Event Registration */
00673     #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_NETAPP_EVENT)
00674     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _NetAppEventHdl) (SlNetAppEvent_t *);
00675     #define SlExtLib5NetAppEventHandler __CONCAT2(SL_EXT_LIB_5, _NetAppEventHdl)
00676 
00677     #undef EXT_LIB_REGISTERED_NETAPP_EVENTS
00678     #define EXT_LIB_REGISTERED_NETAPP_EVENTS
00679     #endif
00680 
00681     /* Http Server Event Registration */
00682     #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_HTTP_SERVER_EVENT)
00683     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _HttpServerEventHdl) (SlHttpServerEvent_t* , SlHttpServerResponse_t*);
00684     #define SlExtLib5HttpServerEventHandler __CONCAT2(SL_EXT_LIB_5, _HttpServerEventHdl)
00685 
00686     #undef EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
00687     #define EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS
00688     #endif
00689 
00690     /* Socket Event Registration */
00691     #if __CONCAT2(SL_EXT_LIB_5, _NOTIFY_SOCK_EVENT)
00692     extern _SlEventPropogationStatus_e __CONCAT2(SL_EXT_LIB_5, _SockEventHdl) (SlSockEvent_t *);
00693     #define SlExtLib5SockEventHandler __CONCAT2(SL_EXT_LIB_5, _SockEventHdl)
00694 
00695     #undef EXT_LIB_REGISTERED_SOCK_EVENTS
00696     #define EXT_LIB_REGISTERED_SOCK_EVENTS
00697     #endif
00698 
00699 #endif
00700 
00701 
00702 
00703 #if defined(EXT_LIB_REGISTERED_GENERAL_EVENTS)
00704 extern void _SlDrvHandleGeneralEvents(SlDeviceEvent_t *slGeneralEvent);
00705 #endif
00706 
00707 #if defined(EXT_LIB_REGISTERED_WLAN_EVENTS)
00708 extern void _SlDrvHandleWlanEvents(SlWlanEvent_t *slWlanEvent);
00709 #endif
00710 
00711 #if defined (EXT_LIB_REGISTERED_NETAPP_EVENTS)
00712 extern void _SlDrvHandleNetAppEvents(SlNetAppEvent_t *slNetAppEvent);
00713 #endif
00714 
00715 #if defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
00716 extern void _SlDrvHandleHttpServerEvents(SlHttpServerEvent_t *slHttpServerEvent, SlHttpServerResponse_t *slHttpServerResponse);
00717 #endif
00718 
00719 
00720 #if defined(EXT_LIB_REGISTERED_SOCK_EVENTS)
00721 extern void _SlDrvHandleSockEvents(SlSockEvent_t *slSockEvent);
00722 #endif
00723 
00724 
00725 typedef short (*_SlSpawnEntryFunc_t)(void* pValue);
00726 
00727 #define SL_SPAWN_FLAG_FROM_SL_IRQ_HANDLER    (0X1)
00728 
00729 #ifdef SL_PLATFORM_MULTI_THREADED
00730     #include "../source/spawn.h"
00731 #else
00732     #include "../source/nonos.h"
00733 #endif
00734 
00735 
00736 
00737 /* Async functions description*/
00738 
00739 /*!
00740     \brief General async event for inspecting general events
00741     
00742     \param[out]      pSlDeviceEvent   pointer to SlDeviceEvent_t 
00743     
00744     \par
00745           Parameters: \n
00746           - <b>pSlDeviceEvent->Event = SL_DEVICE_FATAL_ERROR_EVENT </b>
00747               - pSlDeviceEvent->EventData.deviceEvent fields:      
00748                   - status: An error code indication from the device
00749                   - sender: The sender originator which is based on SlErrorSender_e enum 
00750 
00751         - <b>pSlDeviceEvent->Event = SL_DEVICE_ABORT_ERROR_EVENT </b>
00752               Indicates a severe error occured and the device stopped 
00753               - pSlDeviceEvent->EventData.deviceReport fields:      
00754                   - AbortType: An idication of the event type
00755                   - AbortData: Additional info about the data error 
00756                   
00757       
00758     \par  Example for fatal error:           
00759     \code         
00760     printf(General Event Handler - ID=%d Sender=%d\n\n",
00761            pSlDeviceEvent->EventData.deviceEvent.status,  // status of the general event
00762            pSlDeviceEvent->EventData.deviceEvent.sender); // sender type
00763     \endcode
00764     \par Example for abort request:
00765     \code
00766      printf(Abort type =%d Abort Data=%d\n\n",
00767            pSlDeviceEvent->EventData.deviceReport.AbortType,  
00768            pSlDeviceEvent->EventData.deviceReport.AbortData); 
00769 
00770     \endcode
00771 */
00772 extern void sl_GeneralEvtHdlr(SlDeviceEvent_t *pSlDeviceEvent);
00773 
00774 
00775 /*!
00776     \brief WLAN Async event handler
00777     
00778     \param[out]      pSlWlanEvent   pointer to SlWlanEvent_t data 
00779     
00780     \par
00781              Parameters:
00782              
00783              - <b>pSlWlanEvent->Event = SL_WLAN_CONNECT_EVENT </b>, STA or P2P client connection indication event
00784                  - pSlWlanEvent->EventData.STAandP2PModeWlanConnected main fields:
00785                       - ssid_name
00786                       - ssid_len
00787                       - bssid
00788                       - go_peer_device_name
00789                       - go_peer_device_name_len
00790                        
00791              - <b>pSlWlanEvent->Event = SL_WLAN_DISCONNECT_EVENT </b>, STA or P2P client disconnection event                          
00792                  - pSlWlanEvent->EventData.STAandP2PModeDisconnected main fields:
00793                       - ssid_name
00794                       - ssid_len
00795                       - reason_code
00796 
00797              - <b>pSlWlanEvent->Event = SL_WLAN_STA_CONNECTED_EVENT </b>, AP/P2P(Go) connected STA/P2P(Client)                  
00798                   - pSlWlanEvent->EventData.APModeStaConnected fields:
00799                       - go_peer_device_name
00800                       - mac
00801                       - go_peer_device_name_len
00802                       - wps_dev_password_id
00803                       - own_ssid:  relevant for event sta-connected only
00804                       - own_ssid_len:  relevant for event sta-connected only
00805                       
00806              - <b>pSlWlanEvent->Event = SL_WLAN_STA_DISCONNECTED_EVENT </b>, AP/P2P(Go) disconnected STA/P2P(Client)                        
00807                   - pSlWlanEvent->EventData.APModestaDisconnected fields:
00808                       - go_peer_device_name
00809                       - mac
00810                       - go_peer_device_name_len
00811                       - wps_dev_password_id
00812                       - own_ssid:  relevant for event sta-connected only
00813                       - own_ssid_len:  relevant for event sta-connected only
00814 
00815              - <b>pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_COMPLETE_EVENT </b>                             
00816                   - pSlWlanEvent->EventData.smartConfigStartResponse fields:
00817                      - status
00818                      - ssid_len
00819                      - ssid
00820                      - private_token_len
00821                      - private_token
00822                      
00823              - <b>pSlWlanEvent->Event = SL_WLAN_SMART_CONFIG_STOP_EVENT </b>                 
00824                      - pSlWlanEvent->EventData.smartConfigStopResponse fields:       
00825                          - status
00826                          
00827              - <b>pSlWlanEvent->Event = SL_WLAN_P2P_DEV_FOUND_EVENT </b>         
00828                      - pSlWlanEvent->EventData.P2PModeDevFound fields:
00829                          - go_peer_device_name
00830                          - mac
00831                          - go_peer_device_name_len
00832                          - wps_dev_password_id
00833                          - own_ssid:  relevant for event sta-connected only
00834                          - own_ssid_len:  relevant for event sta-connected only
00835                          
00836              - <b>pSlWlanEvent->Event = SL_WLAN_P2P_NEG_REQ_RECEIVED_EVENT </b>                             
00837                       - pSlWlanEvent->EventData.P2PModeNegReqReceived fields
00838                           - go_peer_device_name
00839                           - mac
00840                           - go_peer_device_name_len
00841                           - wps_dev_password_id
00842                           - own_ssid:  relevant for event sta-connected only
00843                            
00844              - <b>pSlWlanEvent->Event = SL_WLAN_CONNECTION_FAILED_EVENT </b>, P2P only
00845                        - pSlWlanEvent->EventData.P2PModewlanConnectionFailure fields:
00846                            - status                  
00847 */
00848 #if (defined(sl_WlanEvtHdlr))
00849 extern void sl_WlanEvtHdlr(SlWlanEvent_t* pSlWlanEvent);
00850 #endif
00851 
00852 
00853 /*!
00854     \brief NETAPP Async event handler
00855     
00856     \param[out]      pSlNetApp   pointer to SlNetAppEvent_t data    
00857     
00858     \par
00859              Parameters:
00860               - <b>pSlNetApp->Event = SL_NETAPP_IPV4_IPACQUIRED_EVENT</b>, IPV4 acquired event
00861                   - pSlNetApp->EventData.ipAcquiredV4 fields:
00862                        - ip
00863                        - gateway
00864                        - dns
00865                            
00866               - <b>pSlNetApp->Event = SL_NETAPP_IP_LEASED_EVENT</b>, AP or P2P go dhcp lease event
00867                   - pSlNetApp->EventData.ipLeased  fields:
00868                        - ip_address
00869                        - lease_time
00870                        - mac
00871 
00872               - <b>pSlNetApp->Event = SL_NETAPP_IP_RELEASED_EVENT</b>, AP or P2P go dhcp ip release event
00873                    - pSlNetApp->EventData.ipReleased fields
00874                        - ip_address
00875                        - mac
00876                        - reason
00877 
00878 */
00879 #if (defined(sl_NetAppEvtHdlr))
00880 extern void sl_NetAppEvtHdlr(SlNetAppEvent_t* pSlNetApp);
00881 #endif
00882 
00883 /*!
00884     \brief Socket Async event handler
00885     
00886     \param[out]      pSlSockEvent   pointer to SlSockEvent_t data 
00887     
00888     \par
00889              Parameters:\n
00890              - <b>pSlSockEvent->Event = SL_SOCKET_TX_FAILED_EVENT</b>
00891                  - pSlSockEvent->SockTxFailData fields:
00892                      - sd
00893                      - status
00894              - <b>pSlSockEvent->Event = SL_SOCKET_ASYNC_EVENT</b>
00895                 - pSlSockEvent->SockAsyncData fields:
00896                      - sd
00897                      - type: SSL_ACCEPT  or RX_FRAGMENTATION_TOO_BIG or OTHER_SIDE_CLOSE_SSL_DATA_NOT_ENCRYPTED 
00898                      - val
00899 
00900 */
00901 #if (defined(sl_SockEvtHdlr))
00902 extern void sl_SockEvtHdlr(SlSockEvent_t* pSlSockEvent);
00903 #endif
00904 
00905 /*!
00906     \brief HTTP server async event
00907 
00908     \param[out] pSlHttpServerEvent   pointer to SlHttpServerEvent_t
00909     \param[in] pSlHttpServerResponse pointer to SlHttpServerResponse_t
00910 
00911     \par
00912           Parameters: \n
00913 
00914           - <b>pSlHttpServerEvent->Event = SL_NETAPP_HTTPGETTOKENVALUE_EVENT</b>
00915              - pSlHttpServerEvent->EventData fields:
00916                  - httpTokenName
00917                      - data
00918                      - len
00919              - pSlHttpServerResponse->ResponseData fields:
00920                      - data
00921                      - len
00922              
00923           - <b>pSlHttpServerEvent->Event = SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT</b>
00924               - pSlHttpServerEvent->EventData.httpPostData fields:
00925                      - action
00926                      - token_name
00927                      - token_value                     
00928               - pSlHttpServerResponse->ResponseData fields:
00929                      - data
00930                      - len         
00931  
00932 */
00933 #if (defined(sl_HttpServerCallback))
00934 extern void sl_HttpServerCallback(SlHttpServerEvent_t *pSlHttpServerEvent, SlHttpServerResponse_t *pSlHttpServerResponse);
00935 #endif
00936 
00937 
00938 
00939 
00940 /*!
00941     \brief SL get timestamp routine.
00942            It returns the timer counter value in ticks unit.
00943            The counter must count from zero to its max value
00944 
00945     \par
00946           Parameters: \n
00947  
00948 */
00949 #if defined (sl_GetTimestamp)
00950 extern _u32 sl_GetTimestamp(void);
00951 #endif
00952 
00953 /*!
00954 
00955  Close the Doxygen group.
00956  @}
00957 
00958  */
00959  
00960 #ifdef  __cplusplus
00961 }
00962 #endif /* __cplusplus */
00963 
00964 #endif    /*  __SIMPLELINK_H__ */
00965