TI's CC3100 websocket camera demo with Arducam mini ov5642 and freertos. Should work with other M3's. Work in progress test demo.

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers cc3100_netapp.h Source File

cc3100_netapp.h

00001 /*
00002  * netapp.h - CC31xx/CC32xx Host Driver Implementation
00003  *
00004  * Copyright (C) 2014 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 /* Include files                                                             */
00039 /*****************************************************************************/
00040 
00041 #include "cc3100_simplelink.h"
00042 
00043 #ifndef NETAPP_H_
00044 #define    NETAPP_H_
00045 
00046 #include "cc3100_protocol.h"
00047 #include "cc3100_nonos.h"
00048 
00049 namespace mbed_cc3100 {
00050 
00051 /*!
00052 
00053     \addtogroup netapp
00054     @{
00055 
00056 */
00057 
00058 /*****************************************************************************/
00059 /* Macro declarations                                                        */
00060 /*****************************************************************************/
00061 
00062 /*ERROR code*/
00063 const int16_t SL_ERROR_NETAPP_RX_BUFFER_LENGTH_ERROR      = (-230);
00064 
00065 /*  Http Server interface */
00066 const uint8_t MAX_INPUT_STRING                            =  (64); /*  because of WPA */
00067 
00068 const uint8_t MAX_AUTH_NAME_LEN                           =  (20);
00069 const uint8_t MAX_AUTH_PASSWORD_LEN                       =  (20);
00070 const uint8_t MAX_AUTH_REALM_LEN                          =  (20);
00071 
00072 const uint8_t MAX_DEVICE_URN_LEN                          =  (15+1);
00073 const uint8_t MAX_DOMAIN_NAME_LEN                         =  (24+1);
00074 
00075 const uint8_t MAX_ACTION_LEN                              =  (30);
00076 /* Important: in case the max len is changed, make sure the struct sl_NetAppHttpServerSendToken_t in protocol.h is padded correctly! */
00077 const uint8_t MAX_TOKEN_NAME_LEN                          =  (20);
00078 const uint8_t MAX_TOKEN_VALUE_LEN                         =  MAX_INPUT_STRING;
00079 
00080 const int16_t NETAPP_MAX_SERVICE_TEXT_SIZE                =  (256);
00081 const uint8_t NETAPP_MAX_SERVICE_NAME_SIZE                =  (60);
00082 const uint8_t NETAPP_MAX_SERVICE_HOST_NAME_SIZE           =  (64);
00083 
00084 
00085 /* Server Responses */
00086 const uint8_t SL_NETAPP_RESPONSE_NONE                     =  (0);
00087 const uint8_t SL_NETAPP_HTTPSETTOKENVALUE                 =  (1);
00088 
00089 const uint8_t SL_NETAPP_FAMILY_MASK                       =  (0x80);
00090 
00091 /* mDNS types */
00092 const uint32_t SL_NET_APP_MASK_IPP_TYPE_OF_SERVICE        =   (0x00000001);
00093 const uint32_t SL_NET_APP_MASK_DEVICE_INFO_TYPE_OF_SERVICE =  (0x00000002);
00094 const uint32_t SL_NET_APP_MASK_HTTP_TYPE_OF_SERVICE       =   (0x00000004);
00095 const uint32_t SL_NET_APP_MASK_HTTPS_TYPE_OF_SERVICE      =   (0x00000008);
00096 const uint32_t SL_NET_APP_MASK_WORKSATION_TYPE_OF_SERVICE =   (0x00000010);
00097 const uint32_t SL_NET_APP_MASK_GUID_TYPE_OF_SERVICE       =   (0x00000020);
00098 const uint32_t SL_NET_APP_MASK_H323_TYPE_OF_SERVICE       =   (0x00000040);
00099 const uint32_t SL_NET_APP_MASK_NTP_TYPE_OF_SERVICE        =   (0x00000080);
00100 const uint32_t SL_NET_APP_MASK_OBJECITVE_TYPE_OF_SERVICE  =   (0x00000100);
00101 const uint32_t SL_NET_APP_MASK_RDP_TYPE_OF_SERVICE        =   (0x00000200);
00102 const uint32_t SL_NET_APP_MASK_REMOTE_TYPE_OF_SERVICE     =   (0x00000400);
00103 const uint32_t SL_NET_APP_MASK_RTSP_TYPE_OF_SERVICE       =   (0x00000800);
00104 const uint32_t SL_NET_APP_MASK_SIP_TYPE_OF_SERVICE        =   (0x00001000);
00105 const uint32_t SL_NET_APP_MASK_SMB_TYPE_OF_SERVICE        =   (0x00002000);
00106 const uint32_t SL_NET_APP_MASK_SOAP_TYPE_OF_SERVICE       =   (0x00004000);
00107 const uint32_t SL_NET_APP_MASK_SSH_TYPE_OF_SERVICE        =   (0x00008000);
00108 const uint32_t SL_NET_APP_MASK_TELNET_TYPE_OF_SERVICE     =   (0x00010000);
00109 const uint32_t SL_NET_APP_MASK_TFTP_TYPE_OF_SERVICE       =   (0x00020000);
00110 const uint32_t SL_NET_APP_MASK_XMPP_CLIENT_TYPE_OF_SERVICE =  (0x00040000);
00111 const uint32_t SL_NET_APP_MASK_RAOP_TYPE_OF_SERVICE       =   (0x00080000);
00112 const uint32_t SL_NET_APP_MASK_ALL_TYPE_OF_SERVICE        =   (0xFFFFFFFF);
00113 
00114 /********************************************************************************************************/
00115 /* sl_NetAppDnsGetHostByName error codes     */
00116 
00117 const int16_t SL_NET_APP_DNS_QUERY_NO_RESPONSE            =  (-159);  /* DNS query failed, no response                        */
00118 const int16_t SL_NET_APP_DNS_NO_SERVER                    =  (-161);  /* No DNS server was specified                          */
00119 const int16_t SL_NET_APP_DNS_PARAM_ERROR                  =  (-162);  /* mDNS parameters error                                */
00120 const int16_t SL_NET_APP_DNS_QUERY_FAILED                 =  (-163);  /* DNS query failed; no DNS server sent an 'answer'     */
00121 const int16_t SL_NET_APP_DNS_INTERNAL_1                   =  (-164);
00122 const int16_t SL_NET_APP_DNS_INTERNAL_2                   =  (-165);
00123 const int16_t SL_NET_APP_DNS_MALFORMED_PACKET             =  (-166);  /* Improperly formed or corrupted DNS packet received   */
00124 const int16_t SL_NET_APP_DNS_INTERNAL_3                   =  (-167);
00125 const int16_t SL_NET_APP_DNS_INTERNAL_4                   =  (-168);
00126 const int16_t SL_NET_APP_DNS_INTERNAL_5                   =  (-169);
00127 const int16_t SL_NET_APP_DNS_INTERNAL_6                   =  (-170);
00128 const int16_t SL_NET_APP_DNS_INTERNAL_7                   =  (-171);
00129 const int16_t SL_NET_APP_DNS_INTERNAL_8                   =  (-172);
00130 const int16_t SL_NET_APP_DNS_INTERNAL_9                   =  (-173);
00131 const int16_t SL_NET_APP_DNS_MISMATCHED_RESPONSE          =  (-174);  /* Server response type does not match the query request*/
00132 const int16_t SL_NET_APP_DNS_INTERNAL_10                  =  (-175);
00133 const int16_t SL_NET_APP_DNS_INTERNAL_11                  =  (-176);
00134 const int16_t SL_NET_APP_DNS_NO_ANSWER                    =  (-177);  /* No response for one-shot query */
00135 const int16_t SL_NET_APP_DNS_NO_KNOWN_ANSWER              =  (-178);  /* No known answer for query */
00136 const int16_t SL_NET_APP_DNS_NAME_MISMATCH                =  (-179);  /* Illegal service name according to the RFC            */
00137 const int16_t SL_NET_APP_DNS_NOT_STARTED                  =  (-180);  /* mDNS is not running                                  */
00138 const int16_t SL_NET_APP_DNS_HOST_NAME_ERROR              =  (-181);  /* Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763 */
00139 const int16_t SL_NET_APP_DNS_NO_MORE_ENTRIES              =  (-182);  /* No more entries be found.                            */
00140 
00141 const int16_t SL_NET_APP_DNS_MAX_SERVICES_ERROR           =  (-200);  /* Maximum advertise services are already configured    */
00142 const int16_t SL_NET_APP_DNS_IDENTICAL_SERVICES_ERROR     =  (-201);  /* Trying to register a service that is already exists  */
00143 const int16_t SL_NET_APP_DNS_NOT_EXISTED_SERVICE_ERROR    =  (-203);  /* Trying to delete service that does not existed       */
00144 const int16_t SL_NET_APP_DNS_ERROR_SERVICE_NAME_ERROR     =  (-204);  /* Illegal service name according to the RFC            */
00145 const int16_t SL_NET_APP_DNS_RX_PACKET_ALLOCATION_ERROR   =  (-205);  /* Retry request                                        */
00146 const int16_t SL_NET_APP_DNS_BUFFER_SIZE_ERROR            =  (-206);  /* List size buffer is bigger than internally allowed in the NWP */
00147 const int16_t SL_NET_APP_DNS_NET_APP_SET_ERROR            =  (-207);  /* Illegal length of one of the mDNS Set functions      */
00148 const int16_t SL_NET_APP_DNS_GET_SERVICE_LIST_FLAG_ERROR  =  (-208);
00149 const int16_t SL_NET_APP_DNS_NO_CONFIGURATION_ERROR       =  (-209);
00150 
00151 /* Set Dev name error codes  (NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN) */
00152 const int16_t SL_ERROR_DEVICE_NAME_LEN_ERR                =   (-117);
00153 const int16_t SL_ERROR_DEVICE_NAME_INVALID                =   (-118);
00154 /* Set domain name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME) */
00155 const int16_t SL_ERROR_DOMAIN_NAME_LEN_ERR                =   (-119);
00156 const int16_t SL_ERROR_DOMAIN_NAME_INVALID                =   (-120);
00157 
00158 /********************************************************************************************************/
00159 
00160 /* NetApp application IDs */
00161 const uint8_t SL_NET_APP_HTTP_SERVER_ID                   =  (1);
00162 const uint8_t SL_NET_APP_DHCP_SERVER_ID                   =  (2);
00163 const uint8_t SL_NET_APP_MDNS_ID                          =  (4);
00164 const uint8_t SL_NET_APP_DNS_SERVER_ID                    =  (8);
00165 const uint8_t SL_NET_APP_DEVICE_CONFIG_ID                 =  (16);
00166 /* NetApp application set/get options */
00167 const uint8_t NETAPP_SET_DHCP_SRV_BASIC_OPT               =  (0);
00168 /* HTTP server set/get options */
00169 const uint8_t NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER         =  (0);
00170 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK          =  (1);
00171 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_NAME           =  (2);
00172 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD       =  (3);
00173 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_REALM          =  (4);
00174 const uint8_t NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS    =  (5);
00175 
00176 const uint8_t NETAPP_SET_GET_MDNS_CONT_QUERY_OPT          =  (1);
00177 const uint8_t NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT         =  (2);
00178 const uint8_t NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT       =  (3);
00179 
00180 /* DNS server set/get options */
00181 const uint8_t NETAPP_SET_GET_DNS_OPT_DOMAIN_NAME          =  (0);
00182 
00183 /* Device Config set/get options */
00184 const uint8_t NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN      =  (0);
00185 const uint8_t NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME     =  (1);
00186 
00187 
00188 /*****************************************************************************/
00189 /* Structure/Enum declarations                                               */
00190 /*****************************************************************************/
00191 /*
00192  * The below structure depict the constant parameters that are returned in the Async event answer
00193  * according to command/API sl_DnsGetHostByService for IPv4 and IPv6.
00194  *
00195     1Status                     - The status of the response.
00196     2.Address                       - Contains the IP address of the service.
00197     3.Port                          - Contains the port of the service.
00198     4.TextLen                       - Contains the max length of the text that the user wants to get.
00199                                                 it means that if the test of service is bigger that its value than
00200                                                 the text is cut to inout_TextLen value.
00201                                         Output: Contain the length of the text that is returned. Can be full text or part
00202                                                 of the text (see above).
00203 
00204 *
00205  */
00206 typedef struct {
00207     uint16_t   Status;
00208     uint16_t   TextLen;
00209     uint32_t    Port;
00210     uint32_t    Address;
00211 } _GetHostByServiceIPv4AsyncResponse_t;
00212 
00213 /*
00214  * The below struct contains pointers to the output parameters that the user gives
00215  *
00216  */
00217 typedef struct {
00218     int16_t       Status;
00219     uint32_t      *out_pAddr;
00220     uint32_t      *out_pPort;
00221     uint16_t      *inout_TextLen; // in: max len , out: actual len
00222     unsigned char *out_pText;
00223 } _GetHostByServiceAsyncResponse_t;
00224 
00225 typedef struct {
00226     uint32_t    PacketsSent;
00227     uint32_t    PacketsReceived;
00228     uint16_t    MinRoundTime;
00229     uint16_t    MaxRoundTime;
00230     uint16_t    AvgRoundTime;
00231     uint32_t    TestTime;
00232 } SlPingReport_t;
00233 
00234 typedef struct {
00235     uint32_t    PingIntervalTime;       /* delay between pings, in milliseconds */
00236     uint16_t    PingSize;               /* ping packet size in bytes           */
00237     uint16_t    PingRequestTimeout;     /* timeout time for every ping in milliseconds  */
00238     uint32_t    TotalNumberOfAttempts;  /* max number of ping requests. 0 - forever    */
00239     uint32_t    Flags;                  /* flag - 0 report only when finished, 1 - return response for every ping, 2 - stop after 1 successful ping.  */
00240     uint32_t    Ip;                     /* IPv4 address or IPv6 first 4 bytes  */
00241     uint32_t    Ip1OrPaadding;
00242     uint32_t    Ip2OrPaadding;
00243     uint32_t    Ip3OrPaadding;
00244 } SlPingStartCommand_t;
00245 
00246 typedef struct _slHttpServerString_t {
00247     uint8_t     len;
00248     uint8_t     *data;
00249 } slHttpServerString_t;
00250 
00251 typedef struct _slHttpServerData_t {
00252     uint8_t     value_len;
00253     uint8_t     name_len;
00254     uint8_t     *token_value;
00255     uint8_t     *token_name;
00256 } slHttpServerData_t;
00257 
00258 typedef struct _slHttpServerPostData_t {
00259     slHttpServerString_t action;
00260     slHttpServerString_t token_name;
00261     slHttpServerString_t token_value;
00262 } slHttpServerPostData_t;
00263 
00264 typedef union {
00265     slHttpServerString_t     httpTokenName; /* SL_NETAPP_HTTPGETTOKENVALUE */
00266     slHttpServerPostData_t   httpPostData;  /* SL_NETAPP_HTTPPOSTTOKENVALUE */
00267 } SlHttpServerEventData_u;
00268 
00269 typedef union {
00270     slHttpServerString_t token_value;
00271 } SlHttpServerResponsedata_u;
00272 
00273 typedef struct {
00274     uint32_t                Event;
00275     SlHttpServerEventData_u EventData;
00276 } SlHttpServerEvent_t;
00277 
00278 typedef struct {
00279     uint32_t                   Response;
00280     SlHttpServerResponsedata_u ResponseData;
00281 } SlHttpServerResponse_t;
00282 
00283 
00284 typedef struct {
00285     uint32_t   lease_time;
00286     uint32_t   ipv4_addr_start;
00287     uint32_t   ipv4_addr_last;
00288 } SlNetAppDhcpServerBasicOpt_t;
00289 
00290 /*mDNS parameters*/
00291 typedef enum {
00292     SL_NET_APP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE = 1,
00293     SL_NET_APP_FULL_SERVICE_IPV4_TYPE,
00294     SL_NET_APP_SHORT_SERVICE_IPV4_TYPE
00295 
00296 } SlNetAppGetServiceListType_e;
00297 
00298 typedef struct {
00299     uint32_t   service_ipv4;
00300     uint16_t   service_port;
00301     uint16_t   Reserved;
00302 } SlNetAppGetShortServiceIpv4List_t;
00303 
00304 typedef struct {
00305     uint32_t   service_ipv4;
00306     uint16_t   service_port;
00307     uint16_t   Reserved;
00308     uint8_t    service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
00309     uint8_t    service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
00310 } SlNetAppGetFullServiceIpv4List_t;
00311 
00312 typedef struct {
00313     uint32_t    service_ipv4;
00314     uint16_t    service_port;
00315     uint16_t    Reserved;
00316     uint8_t     service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
00317     uint8_t     service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
00318     uint8_t     service_text[NETAPP_MAX_SERVICE_TEXT_SIZE];
00319 } SlNetAppGetFullServiceWithTextIpv4List_t;
00320 
00321 typedef struct {
00322     /*The below parameters are used to configure the advertise times and interval
00323     For example:
00324         If:
00325         Period is set to T
00326         Repetitions are set to P
00327         Telescopic factor is K=2
00328         The transmission shall be:
00329         advertise P times
00330         wait T
00331         advertise P times
00332         wait 4 * T
00333         advertise P time
00334         wait 16 * T  ... (till max time reached / configuration changed / query issued)
00335     */
00336     uint32_t    t;              /* Number of ticks for the initial period. Default is 100 ticks for 1 second. */
00337     uint32_t    p;              /* Number of repetitions. Default value is 1                                  */
00338     uint32_t    k;              /* Telescopic factor. Default value is 2.                                     */
00339     uint32_t    RetransInterval;/* Announcing retransmission interval                                         */
00340     uint32_t    Maxinterval;     /* Announcing max period interval                                            */
00341     uint32_t    max_time;       /* Announcing max time                                                        */
00342 } SlNetAppServiceAdvertiseTimingParameters_t;
00343 
00344 /*****************************************************************************/
00345 /* Types declarations                                               */
00346 /*****************************************************************************/
00347 typedef void (*P_SL_DEV_PING_CALLBACK)(SlPingReport_t*);
00348 extern P_SL_DEV_PING_CALLBACK  pPingCallBackFunc;
00349 
00350 /*****************************************************************************************
00351 *   NETAPP structs
00352 ******************************************************************************************/
00353 
00354 
00355 typedef _BasicResponse_t _NetAppStartStopResponse_t;
00356 
00357 typedef struct {
00358     uint32_t  appId;
00359 } _NetAppStartStopCommand_t;
00360 
00361 typedef struct {
00362     uint16_t  Status;
00363     uint16_t  AppId;
00364     uint16_t  ConfigOpt;
00365     uint16_t  ConfigLen;
00366 } _NetAppSetGet_t;
00367 typedef struct {
00368     uint16_t  port_number;
00369 } _NetAppHttpServerGetSet_port_num_t;
00370 
00371 typedef struct {
00372     uint8_t  auth_enable;
00373 } _NetAppHttpServerGetSet_auth_enable_t;
00374 
00375 typedef struct _sl_NetAppHttpServerGetToken_t {
00376     uint8_t   token_name_len;
00377     uint8_t   padd1;
00378     uint16_t  padd2;
00379 } sl_NetAppHttpServerGetToken_t;
00380 
00381 typedef struct _sl_NetAppHttpServerSendToken_t {
00382     uint8_t   token_value_len;
00383     uint8_t   token_name_len;
00384     uint8_t   token_name[MAX_TOKEN_NAME_LEN];
00385     uint16_t  padd;
00386 } sl_NetAppHttpServerSendToken_t;
00387 
00388 typedef struct _sl_NetAppHttpServerPostToken_t {
00389     uint8_t post_action_len;
00390     uint8_t token_name_len;
00391     uint8_t token_value_len;
00392     uint8_t padding;
00393 } sl_NetAppHttpServerPostToken_t;
00394 
00395 
00396 typedef struct {
00397     uint16_t Len;
00398     uint8_t  family;
00399     uint8_t  padding;
00400 } _GetHostByNameCommand_t;
00401 
00402 typedef struct {
00403     uint16_t status;
00404     uint16_t padding;
00405     uint32_t ip0;
00406     uint32_t ip1;
00407     uint32_t ip2;
00408     uint32_t ip3;
00409 } _GetHostByNameIPv6AsyncResponse_t;
00410 
00411 typedef struct {
00412     uint16_t status;
00413     uint8_t  padding1;
00414     uint8_t  padding2;
00415     uint32_t ip0;
00416 } _GetHostByNameIPv4AsyncResponse_t;
00417 
00418 typedef enum {
00419     CTST_BSD_UDP_TX,
00420     CTST_BSD_UDP_RX,
00421     CTST_BSD_TCP_TX,
00422     CTST_BSD_TCP_RX,
00423     CTST_BSD_TCP_SERVER_BI_DIR,
00424     CTST_BSD_TCP_CLIENT_BI_DIR,
00425     CTST_BSD_UDP_BI_DIR,
00426     CTST_BSD_RAW_TX,
00427     CTST_BSD_RAW_RX,
00428     CTST_BSD_RAW_BI_DIR,
00429     CTST_BSD_SECURED_TCP_TX,
00430     CTST_BSD_SECURED_TCP_RX,
00431     CTST_BSD_SECURED_TCP_SERVER_BI_DIR,
00432     CTST_BSD_SECURED_TCP_CLIENT_BI_DIR
00433 } CommTest_e;
00434 
00435 typedef struct _sl_protocol_CtestStartCommand_t {
00436     uint32_t Test;
00437     uint16_t DestPort;
00438     uint16_t SrcPort;
00439     uint32_t DestAddr[4];
00440     uint32_t PayloadSize;
00441     uint32_t timeout;
00442     uint32_t csEnabled;
00443     uint32_t secure;
00444     uint32_t rawProtocol;
00445     uint8_t  reserved1[4];
00446 } _CtestStartCommand_t;
00447 
00448 typedef struct {
00449     uint8_t  test;
00450     uint8_t  socket;
00451     int16_t  status;
00452     uint32_t startTime;
00453     uint32_t endTime;
00454     uint16_t txKbitsSec;
00455     uint16_t rxKbitsSec;
00456     uint32_t outOfOrderPackets;
00457     uint32_t missedPackets;
00458     int16_t  token;
00459 } _CtestAsyncResponse_t;
00460 
00461 typedef struct {
00462     uint32_t pingIntervalTime;
00463     uint16_t PingSize;
00464     uint16_t pingRequestTimeout;
00465     uint32_t totalNumberOfAttempts;
00466     uint32_t flags;
00467     uint32_t ip0;
00468     uint32_t ip1OrPaadding;
00469     uint32_t ip2OrPaadding;
00470     uint32_t ip3OrPaadding;
00471 } _PingStartCommand_t;
00472 
00473 typedef struct {
00474     uint16_t status;
00475     uint16_t rttMin;
00476     uint16_t rttMax;
00477     uint16_t rttAvg;
00478     uint32_t numSuccsessPings;
00479     uint32_t numSendsPings;
00480     uint32_t testTime;
00481 } _PingReportResponse_t;
00482 
00483 
00484 typedef struct {
00485     uint32_t ip;
00486     uint32_t gateway;
00487     uint32_t dns;
00488 } _IpV4AcquiredAsync_t;
00489 
00490 
00491 typedef enum {
00492     ACQUIRED_IPV6_LOCAL = 1,
00493     ACQUIRED_IPV6_GLOBAL
00494 } IpV6AcquiredType_e;
00495 
00496 
00497 typedef struct {
00498     uint32_t type;
00499     uint32_t ip[4];
00500     uint32_t gateway[4];
00501     uint32_t dns[4];
00502 } _IpV6AcquiredAsync_t;
00503 
00504 
00505 typedef union {
00506     _SocketCommand_t     EventMask;
00507     _sendRecvCommand_t   DeviceInit;
00508 } _device_commands_t;
00509 
00510 
00511 class cc3100_netapp
00512 {
00513 
00514 public:
00515 
00516 #ifndef SL_PLATFORM_MULTI_THREADED
00517     cc3100_netapp(cc3100_driver &driver, cc3100_nonos &nonos);
00518 #else
00519     cc3100_netapp(cc3100_driver &driver);
00520 #endif    
00521 
00522     ~cc3100_netapp();
00523 
00524     /*****************************************************************************/
00525     /* Functions prototypes                                                      */
00526     /*****************************************************************************/
00527     int16_t sl_NetAppMDNSRegisterUnregisterService(const char* pServiceName,  
00528                                                    const uint8_t ServiceNameLen, 
00529                                                    const char* pText, 
00530                                                    const uint8_t TextLen, 
00531                                                    const uint16_t Port, 
00532                                                    const uint32_t TTL, 
00533                                                    const uint32_t Options);
00534 
00535     void _sl_HandleAsync_DnsGetHostByAddr(void *pVoidBuf);
00536 
00537     void CopyPingResultsToReport(_PingReportResponse_t *pResults,SlPingReport_t *pReport);
00538     
00539 #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
00540     uint16_t sl_NetAppSendTokenValue(slHttpServerData_t * Token);
00541 #endif
00542 
00543 //    uint16_t sl_NetAppSendTokenValue(slHttpServerData_t * Token);
00544 
00545 
00546     /*****************************************************************************/
00547     /* Function prototypes                                                       */
00548     /*****************************************************************************/
00549 
00550 
00551     /*!
00552         \brief Starts a network application
00553 
00554         Gets and starts network application for the current WLAN mode
00555 
00556         \param[in] AppBitMap      application bitmap, could be one or combination of the following: \n
00557                                   - SL_NET_APP_HTTP_SERVER_ID
00558                                   - SL_NET_APP_DHCP_SERVER_ID
00559                                   - SL_NET_APP_MDNS_ID
00560 
00561         \return                   On error, negative number is returned
00562 
00563         \sa                       Stop one or more the above started applications using sl_NetAppStop
00564         \note                     This command activates the application for the current WLAN mode (AP or STA)
00565         \warning
00566         \par                 Example:
00567         \code
00568         For example: Starting internal HTTP server + DHCP server:
00569         sl_NetAppStart(SL_NET_APP_HTTP_SERVER_ID | SL_NET_APP_DHCP_SERVER_ID)
00570 
00571         \endcode
00572     */
00573 #if _SL_INCLUDE_FUNC(sl_NetAppStart)
00574     int16_t sl_NetAppStart(const uint32_t AppBitMap);
00575 #endif
00576     /*!
00577         \brief Stops a network application
00578 
00579         Gets and stops network application for the current WLAN mode
00580 
00581         \param[in] AppBitMap    application id, could be one of the following: \n
00582                                 - SL_NET_APP_HTTP_SERVER_ID
00583                                 - SL_NET_APP_DHCP_SERVER_ID
00584                                 - SL_NET_APP_MDNS_ID
00585 
00586         \return                 On error, negative number is returned
00587 
00588         \sa
00589         \note                This command disables the application for the current active WLAN mode (AP or STA)
00590         \warning
00591         \par                 Example:
00592         \code
00593 
00594         For example: Stopping internal HTTP server:
00595                              sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID);
00596 
00597         \endcode
00598     */
00599 #if _SL_INCLUDE_FUNC(sl_NetAppStop)
00600     int16_t sl_NetAppStop(const uint32_t AppBitMap);
00601 #endif
00602 
00603     /*!
00604         \brief Get host IP by name
00605 
00606         Obtain the IP Address of machine on network, by machine name.
00607 
00608         \param[in]  hostname        host name
00609         \param[in]  usNameLen       name length
00610         \param[out] out_ip_addr     This parameter is filled in with
00611                                     host IP address. In case that host name is not
00612                                     resolved, out_ip_addr is zero.
00613         \param[in]  family          protocol family
00614 
00615         \return                     On success, 0 is returned.
00616                                     On error, negative is returned
00617                                     SL_POOL_IS_EMPTY may be return in case there are no resources in the system
00618                                     In this case try again later or increase MAX_CONCURRENT_ACTIONS
00619                                     Possible DNS error codes:
00620                                     - SL_NET_APP_DNS_QUERY_NO_RESPONSE
00621                                     - SL_NET_APP_DNS_NO_SERVER
00622                                     - SL_NET_APP_DNS_QUERY_FAILED
00623                                     - SL_NET_APP_DNS_MALFORMED_PACKET
00624                                     - SL_NET_APP_DNS_MISMATCHED_RESPONSE
00625 
00626         \sa
00627         \note   Only one sl_NetAppDnsGetHostByName can be handled at a time.
00628                 Calling this API while the same command is called from another thread, may result
00629                 in one of the two scenarios:
00630                 1. The command will wait (internal) until the previous command finish, and then be executed.
00631                 2. There are not enough resources and POOL_IS_EMPTY error will return.
00632                 In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
00633                 again later to issue the command.
00634         \warning
00635         In case an IP address in a string format is set as input, without any prefix (e.g. "1.2.3.4") the device will not 
00636         try to access the DNS and it will return the input address on the 'out_ip_addr' field 
00637         \par  Example:
00638         \code
00639         uint32_t DestinationIP;
00640         sl_NetAppDnsGetHostByName("www.google.com", strlen("www.google.com"), &DestinationIP,SL_AF_INET);
00641 
00642         Addr.sin_family = SL_AF_INET;
00643         Addr.sin_port = sl_Htons(80);
00644         Addr.sin_addr.s_addr = sl_Htonl(DestinationIP);
00645         AddrSize = sizeof(SlSockAddrIn_t);
00646         SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
00647         \endcode
00648     */
00649 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByName)
00650     int16_t sl_NetAppDnsGetHostByName(unsigned char * hostname, const uint16_t usNameLen, uint32_t*  out_ip_addr, const uint8_t family );
00651 #endif
00652 
00653     /*!
00654             \brief Return service attributes like IP address, port and text according to service name
00655             \par
00656             The user sets a service name Full/Part (see example below), and should get:
00657             - IP of service
00658             - The port of service
00659             - The text of service
00660 
00661             Hence it can make a connection to the specific service and use it.
00662             It is similar to get host by name method.
00663             It is done by a single shot query with PTR type on the service name.
00664                       The command that is sent is from constant parameters and variables parameters.
00665 
00666             \param[in]     pService                   Service name can be full or partial. \n
00667                                                       Example for full service name:
00668                                                       1. PC1._ipp._tcp.local
00669                                                       2. PC2_server._ftp._tcp.local \n
00670                                                       .
00671                                                       Example for partial service name:
00672                                                       1. _ipp._tcp.local
00673                                                       2. _ftp._tcp.local
00674 
00675             \param[in]    ServiceLen                  The length of the service name (in_pService).
00676             \param[in]    Family                      IPv4 or IPv6 (SL_AF_INET , SL_AF_INET6).
00677             \param[out]    pAddr                      Contains the IP address of the service.
00678             \param[out]    pPort                      Contains the port of the service.
00679             \param[out]    pTextLen                   Has 2 options. One as Input field and the other one as output:
00680                                                       - Input: \n
00681                                                       Contains the max length of the text that the user wants to get.\n
00682                                                       It means that if the text len of service is bigger that its value than
00683                                                       the text is cut to inout_TextLen value.
00684                                                       - Output: \n
00685                                                        Contain the length of the text that is returned. Can be full text or part of the text (see above).
00686 
00687             \param[out]   pOut_pText     Contains the text of the service full or partial
00688 
00689             \return       On success, zero is returned
00690                           SL_POOL_IS_EMPTY may be return in case there are no resources in the system
00691                           In this case try again later or increase MAX_CONCURRENT_ACTIONS
00692                           In case No service is found error SL_NET_APP_DNS_NO_ANSWER will be returned
00693 
00694             \note         The returns attributes belongs to the first service found.
00695                           There may be other services with the same service name that will response to the query.
00696                           The results of these responses are saved in the peer cache of the Device and should be read by another API.
00697 
00698                           Only one sl_NetAppDnsGetHostByService can be handled at a time.
00699                           Calling this API while the same command is called from another thread, may result
00700                           in one of the two scenarios:
00701                           1. The command will wait (internal) until the previous command finish, and then be executed.
00702                           2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
00703                           In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
00704                           again later to issue the command.
00705 
00706             \warning      Text length can be 120 bytes only
00707     */
00708 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByService)
00709     int32_t sl_NetAppDnsGetHostByService(unsigned char  *pServiceName, /*  string containing all (or only part): name + subtype + service */
00710                                          const uint8_t  ServiceLen,
00711                                          const uint8_t  Family,        /*  4-IPv4 , 16-IPv6  */
00712                                          uint32_t pAddr[],
00713                                          uint32_t *pPort,
00714                                          uint16_t *pTextLen,     /*  in: max len , out: actual len */
00715                                          unsigned char  *pText
00716                                         );
00717 
00718 #endif
00719 
00720     /*!
00721             \brief Get service List
00722             Insert into out pBuffer a list of peer's services that are the NWP.
00723             The list is in a form of service struct. The user should chose the type
00724             of the service struct like:
00725                 - Full service parameters with text.
00726                 - Full service parameters.
00727                 - Short service parameters (port and IP only) especially for tiny hosts.
00728 
00729             The different types of struct are made to give the
00730             Possibility to save memory in the host
00731 
00732 
00733             The user also chose how many max services to get and start point index
00734             NWP peer cache.
00735             For example:
00736                 1.    Get max of 3 full services from index 0.Up to 3 full services
00737                 from index 0 are inserted into pBuffer (services that are in indexes 0,1,2).
00738                 2.    Get max of 4 full services from index 3.Up to 4 full services
00739                 from index 3 are inserted into pBuffer (services that are in indexes 3,4,5,6).
00740                 3.    Get max of 2 int services from index 6.Up to 2 int services
00741                 from index 6 are inserted into pBuffer (services that are in indexes 6,7).
00742 
00743             See below - command parameters.
00744 
00745             \param[in] indexOffset - The start index in the peer cache that from it the first service is returned.
00746             \param[in] MaxServiceCount - The Max services that can be returned if existed or if not exceed the max index
00747                           in the peer cache
00748             \param[in] Flags - an ENUM number that means which service struct to use (means which types of service to fill)
00749                             - use SlNetAppGetFullServiceWithTextIpv4List_t
00750                             - use SlNetAppGetFullServiceIpv4List_t
00751                             - use SlNetAppGetShortServiceIpv4List_t
00752 
00753            \param[out]  Buffer - The Services are inserted into this buffer. In the struct form according to the bit that is set in the Flags
00754                           input parameter.
00755 
00756             \return    ServiceFoundCount - The number of the services that were inserted into the buffer. zero means no service is found
00757                         negative number means an error
00758             \sa           sl_NetAppMDNSRegisterService
00759             \note
00760             \warning
00761                         if the out pBuffer size is bigger than an RX packet(1480), than
00762                         an error is returned because there
00763                         is no place in the RX packet.
00764                         The size is a multiply of MaxServiceCount and size of service struct(that is set
00765                         according to flag value).
00766     */
00767 
00768 #if _SL_INCLUDE_FUNC(sl_NetAppGetServiceList)
00769     int16_t sl_NetAppGetServiceList(const uint8_t   IndexOffest,
00770                                     const uint8_t   MaxServiceCount,
00771                                     const uint8_t   Flags,
00772                                     int8_t   *pBuffer,
00773                                     const uint32_t  RxBufferLength
00774                                    );
00775 
00776 #endif
00777 
00778     /*!
00779             \brief Unregister mDNS service
00780             This function deletes the mDNS service from the mDNS package and the database.
00781 
00782             The mDNS service that is to be unregistered is a service that the application no longer wishes to provide. \n
00783             The service name should be the full service name according to RFC
00784             of the DNS-SD - meaning the value in name field in the SRV answer.
00785 
00786             Examples for service names:
00787             1. PC1._ipp._tcp.local
00788             2. PC2_server._ftp._tcp.local
00789 
00790             \param[in]    pServiceName            Full service name. \n
00791                                                     Example for service name:
00792                                                     1. PC1._ipp._tcp.local
00793                                                     2. PC2_server._ftp._tcp.local
00794             \param[in]    ServiceLen              The length of the service.
00795             \return    On success, zero is returned
00796             \sa          sl_NetAppMDNSRegisterService
00797             \note
00798             \warning
00799             The size of the service length should be smaller than 255.
00800     */
00801 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService)
00802     int16_t sl_NetAppMDNSUnRegisterService(const char *pServiceName, const uint8_t ServiceNameLen);
00803 #endif
00804 
00805     /*!
00806             \brief Register a new mDNS service
00807             \par
00808             This function registers a new mDNS service to the mDNS package and the DB.
00809 
00810             This registered service is a service offered by the application.
00811             The service name should be full service name according to RFC
00812             of the DNS-SD - meaning the value in name field in the SRV answer.
00813             Example for service name:
00814             1. PC1._ipp._tcp.local
00815             2. PC2_server._ftp._tcp.local
00816 
00817             If the option is_unique is set, mDNS probes the service name to make sure
00818             it is unique before starting to announce the service on the network.
00819             Instance is the instance portion of the service name.
00820 
00821             \param[in]  ServiceLen         The length of the service.
00822             \param[in]  TextLen            The length of the service should be smaller than 64.
00823             \param[in]  port               The port on this target host port.
00824             \param[in]  TTL                The TTL of the service
00825             \param[in]  Options            bitwise parameters: \n
00826                                            - bit 0  - service is unique (means that the service needs to be unique)
00827                                            - bit 31  - for internal use if the service should be added or deleted (set means ADD).
00828                                            - bit 1-30 for future.
00829 
00830             \param[in]    pServiceName              The service name.
00831                                            Example for service name: \n
00832                                                     1. PC1._ipp._tcp.local
00833                                                     2. PC2_server._ftp._tcp.local
00834 
00835             \param[in] pText                     The description of the service.
00836                                                     should be as mentioned in the RFC
00837                                                     (according to type of the service IPP,FTP...)
00838 
00839             \return     On success, zero is returned
00840                         Possible error codes:
00841                         - Maximum advertise services are already configured.
00842                                     Delete another existed service that is registered and then register again the new service
00843                         - Trying to register a service that is already exists
00844                         - Trying to delete service that does not existed
00845                         - Illegal service name according to the RFC
00846                         - Retry request
00847                         - Illegal length of one of the mDNS Set functions
00848                         - mDNS is not operational as the device has no IP.Connect the device to an AP to get an IP address.
00849                         - mDNS parameters error
00850                         - mDNS internal cache error
00851                         - mDNS internal error
00852                         - Adding a service is not allowed as it is already exist (duplicate service)
00853                         - mDNS is not running
00854                         - Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763
00855                         - List size buffer is bigger than internally allowed in the NWP (API get service list),
00856                          change the APIs� parameters to decrease the size of the list
00857 
00858 
00859             \sa              sl_NetAppMDNSUnRegisterService
00860 
00861             \warning      1) Temporary -  there is an allocation on stack of internal buffer.
00862                         Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. \n
00863                         It means that the sum of the text length and service name length cannot be bigger than
00864                         NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.\n
00865                         If it is - An error is returned. \n
00866                         2) According to now from certain constraints the variables parameters are set in the
00867                         attribute part (contain constant parameters)
00868     */
00869 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService)
00870     int16_t sl_NetAppMDNSRegisterService( const char*  pServiceName,
00871                                           const uint8_t         ServiceNameLen,
00872                                           const char*  pText,
00873                                           const uint8_t         TextLen,
00874                                           const uint16_t        Port,
00875                                           const uint32_t        TTL,
00876                                           uint32_t        Options);
00877 #endif
00878 
00879     /*!
00880         \brief send ICMP ECHO_REQUEST to network hosts
00881 
00882         Ping uses the ICMP protocol's mandatory ECHO_REQUEST
00883 
00884         \param[in]   pPingParams     Pointer to the ping request structure: \n
00885                                      - if flags parameter is set to 0, ping will report back once all requested pings are done (as defined by TotalNumberOfAttempts). \n
00886                                      - if flags parameter is set to 1, ping will report back after every ping, for TotalNumberOfAttempts.
00887                                      - if flags parameter is set to 2, ping will stop after the first successful ping, and report back for the successful ping, as well as any preceding failed ones.
00888                                      For stopping an ongoing ping activity, set parameters IP address to 0
00889 
00890         \param[in]   family          SL_AF_INET or  SL_AF_INET6
00891         \param[out]  pReport         Ping pReport
00892         \param[out]  pCallback       Callback function upon completion.
00893                                      If callback is NULL, the API is blocked until data arrives
00894 
00895 
00896         \return    On success, zero is returned. On error, -1 is returned
00897                    SL_POOL_IS_EMPTY may be return in case there are no resources in the system
00898                    In this case try again later or increase MAX_CONCURRENT_ACTIONS
00899 
00900         \sa       sl_NetAppPingReport
00901         \note      Only one sl_NetAppPingStart can be handled at a time.
00902                   Calling this API while the same command is called from another thread, may result
00903                       in one of the two scenarios:
00904                   1. The command will wait (internal) until the previous command finish, and then be executed.
00905                   2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
00906                   In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
00907                   again later to issue the command.
00908         \warning
00909         \par      Example:
00910         \code
00911 
00912         An example of sending 20 ping requests and reporting results to a callback routine when
00913                   all requests are sent:
00914 
00915                   // callback routine
00916                   void pingRes(SlPingReport_t* pReport)
00917                   {
00918                    // handle ping results
00919                   }
00920 
00921                   // ping activation
00922                   void PingTest()
00923                   {
00924                      SlPingReport_t report;
00925                      SlPingStartCommand_t pingCommand;
00926 
00927                      pingCommand.Ip = SL_IPV4_VAL(10,1,1,200);     // destination IP address is 10.1.1.200
00928                      pingCommand.PingSize = 150;                   // size of ping, in bytes
00929                      pingCommand.PingIntervalTime = 100;           // delay between pings, in milliseconds
00930                      pingCommand.PingRequestTimeout = 1000;        // timeout for every ping in milliseconds
00931                      pingCommand.TotalNumberOfAttempts = 20;       // max number of ping requests. 0 - forever
00932                      pingCommand.Flags = 0;                        // report only when finished
00933 
00934                      sl_NetAppPingStart( &pingCommand, SL_AF_INET, &report, pingRes ) ;
00935                  }
00936 
00937         \endcode
00938     */
00939 #if _SL_INCLUDE_FUNC(sl_NetAppPingStart)
00940     int16_t sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams, const uint8_t family,SlPingReport_t *pReport, const P_SL_DEV_PING_CALLBACK pPingCallback);
00941 #endif
00942 
00943     /*!
00944         \brief     Internal function for setting network application configurations
00945 
00946         \return    On success, zero is returned. On error, -1 is
00947                    returned
00948 
00949         \param[in] AppId          Application id, could be one of the following: \n
00950                                   - SL_NET_APP_HTTP_SERVER_ID
00951                                   - SL_NET_APP_DHCP_SERVER_ID
00952                                   - SL_NET_APP_MDNS_ID
00953                                   - SL_NET_APP_DEVICE_CONFIG_ID
00954 
00955         \param[in] SetOptions     set option, could be one of the following: \n
00956                                   - SL_NET_APP_DHCP_SERVER_ID
00957                                  - NETAPP_SET_DHCP_SRV_BASIC_OPT
00958                                  - SL_NET_APP_HTTP_SERVER_ID
00959                                  - NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
00960                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
00961                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
00962                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
00963                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
00964                                  - NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
00965                                  - SL_NET_APP_MDNS_ID
00966                                  - NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
00967                                  - NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
00968                                  - NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
00969                                  - SL_NET_APP_DEVICE_CONFIG_ID
00970                                  - NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
00971                                  - NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
00972 
00973 
00974         \param[in] OptionLen       option structure length
00975 
00976         \param[in] pOptionValues   pointer to the option structure
00977         \sa
00978         \note
00979         \warning
00980         \par
00981         \code
00982             Set DHCP Server (AP mode) parameters example:
00983 
00984             SlNetAppDhcpServerBasicOpt_t dhcpParams;
00985             uint8_t outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
00986             dhcpParams.lease_time      = 4096;                         // lease time (in seconds) of the IP Address
00987             dhcpParams.ipv4_addr_start =  SL_IPV4_VAL(192,168,1,10);   // first IP Address for allocation. IP Address should be set as Hex number - i.e. 0A0B0C01 for (10.11.12.1)
00988             dhcpParams.ipv4_addr_last  =  SL_IPV4_VAL(192,168,1,16);   // last IP Address for allocation. IP Address should be set as Hex number - i.e. 0A0B0C01 for (10.11.12.1)
00989             sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID);                  // Stop DHCP server before settings
00990             sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, outLen, (uint8_t* )&dhcpParams);  // set parameters
00991             sl_NetAppStart(SL_NET_APP_DHCP_SERVER_ID);                 // Start DHCP server with new settings
00992         \endcode
00993         \code
00994             Set Device URN name example:
00995 
00996             Device name, maximum length of 33 characters
00997             Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
00998             In case no device URN name set, the default name is "mysimplelink"
00999             Allowed characters in device name are: 'a - z' , 'A - Z' , '0-9' and '-'
01000 
01001             uint8_t *my_device = "MY-SIMPLELINK-DEV";
01002             sl_NetAppSet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(my_device), (uint8_t *) my_device);
01003         \endcode
01004 
01005     */
01006 #if _SL_INCLUDE_FUNC(sl_NetAppSet)
01007     int32_t sl_NetAppSet(const uint8_t AppId, const uint8_t Option, const uint8_t OptionLen, const uint8_t *pOptionValue);
01008 #endif
01009 
01010     /*!
01011         \brief     Internal function for getting network applications configurations
01012 
01013         \return    On success, zero is returned. On error, -1 is
01014                    returned
01015 
01016         \param[in] AppId          Application id, could be one of the following: \n
01017                                   - SL_NET_APP_HTTP_SERVER_ID
01018                                   - SL_NET_APP_DHCP_SERVER_ID
01019                                   - SL_NET_APP_MDNS_ID
01020                                   - SL_NET_APP_DEVICE_CONFIG_ID
01021 
01022     \param[in] SetOptions     set option, could be one of the following: \n
01023                                  - SL_NET_APP_DHCP_SERVER_ID
01024                                  - NETAPP_SET_DHCP_SRV_BASIC_OPT
01025                                  - SL_NET_APP_HTTP_SERVER_ID
01026                                  - NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
01027                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
01028                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
01029                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
01030                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
01031                                  - NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
01032                                  - SL_NET_APP_MDNS_ID
01033                                  - NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
01034                                  - NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
01035                                  - NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
01036                                  - SL_NET_APP_DEVICE_CONFIG_ID
01037                                  - NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
01038                                  - NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
01039 
01040         \param[in] OptionLen     The length of the allocated memory as input, when the
01041                                             function complete, the value of this parameter would be
01042                                             the len that actually read from the device.
01043                                             If the device return length that is longer from the input
01044                                             value, the function will cut the end of the returned structure
01045                                             and will return ESMALLBUF
01046 
01047         \param[out] pValues      pointer to the option structure which will be filled with the response from the device
01048 
01049         \sa
01050         \note
01051         \warning
01052         \par
01053         \code
01054              Get DHCP Server parameters example:
01055 
01056              SlNetAppDhcpServerBasicOpt_t dhcpParams;
01057              uint8_t outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
01058              sl_NetAppGet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, &outLen, (uint8_t* )&dhcpParams);
01059 
01060              printf("DHCP Start IP %d.%d.%d.%d End IP %d.%d.%d.%d Lease time seconds %d\n",
01061                 SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,2),
01062                 SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,0),
01063                 SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,2),
01064                 SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,0),
01065                 dhcpParams.lease_time);
01066         \endcode
01067         \code
01068              Get Device URN name example:
01069              Maximum length of 33 characters of device name.
01070              Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
01071              in case no device URN name set, the default name is "mysimplelink"
01072 
01073              uint8_t my_device_name[35];
01074              sl_NetAppGet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(my_device_name), (uint8_t *)my_device_name);
01075         \endcode
01076     */
01077 #if _SL_INCLUDE_FUNC(sl_NetAppGet)
01078     int32_t sl_NetAppGet(const uint8_t AppId, const uint8_t Option,uint8_t *pOptionLen, uint8_t *pOptionValue);
01079 #endif
01080 
01081 private:
01082 
01083     cc3100_driver           &_driver;
01084 #ifndef SL_PLATFORM_MULTI_THREADED    
01085     cc3100_nonos            &_nonos;
01086 #endif
01087 
01088 };//class
01089 
01090 /*****************************************************************************/
01091 /* Macro declarations                                                        */
01092 /*****************************************************************************/
01093 const uint8_t FLOW_CONT_MIN = 1;
01094 
01095 
01096 class cc3100_flowcont
01097 {
01098 
01099 public:
01100 
01101 #ifndef SL_PLATFORM_MULTI_THREADED
01102     cc3100_flowcont(cc3100_driver &driver, cc3100_nonos &nonos);
01103 #else
01104     cc3100_flowcont(cc3100_driver &driver);
01105 #endif
01106 
01107     ~cc3100_flowcont();
01108 
01109 #if 0
01110     /*****************************************************************************/
01111     /* Function prototypes                                                       */
01112     /*****************************************************************************/
01113     void _SlDrvFlowContInit(void);
01114     void _SlDrvFlowContDeinit(void);
01115 #endif
01116 
01117 private:
01118 
01119     cc3100_driver &_driver;
01120 #ifndef SL_PLATFORM_MULTI_THREADED    
01121     cc3100_nonos  &_nonos;
01122 #endif    
01123 
01124 };//class
01125 }//namespace mbed_cc3100
01126 
01127 /*!
01128 
01129  Close the Doxygen group.
01130  @}
01131 
01132  */
01133 
01134 #endif    /*  __NETAPP_H__ */
01135 
01136