Update revision to use TI's mqtt and Freertos.

Dependencies:   mbed client server

Fork of cc3100_Test_mqtt_CM3 by David Fletcher

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     cc3100_netapp(cc3100_driver &driver, cc3100_nonos &nonos);
00517 
00518     ~cc3100_netapp();
00519 
00520     /*****************************************************************************/
00521     /* Functions prototypes                                                      */
00522     /*****************************************************************************/
00523     int16_t sl_NetAppMDNSRegisterUnregisterService(const char* pServiceName,  
00524                                                    const uint8_t ServiceNameLen, 
00525                                                    const char* pText, 
00526                                                    const uint8_t TextLen, 
00527                                                    const uint16_t Port, 
00528                                                    const uint32_t TTL, 
00529                                                    const uint32_t Options);
00530 
00531     void _sl_HandleAsync_DnsGetHostByAddr(void *pVoidBuf);
00532 
00533     void CopyPingResultsToReport(_PingReportResponse_t *pResults,SlPingReport_t *pReport);
00534     
00535 #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
00536     uint16_t sl_NetAppSendTokenValue(slHttpServerData_t * Token);
00537 #endif
00538 
00539 //    uint16_t sl_NetAppSendTokenValue(slHttpServerData_t * Token);
00540 
00541 
00542     /*****************************************************************************/
00543     /* Function prototypes                                                       */
00544     /*****************************************************************************/
00545 
00546 
00547     /*!
00548         \brief Starts a network application
00549 
00550         Gets and starts network application for the current WLAN mode
00551 
00552         \param[in] AppBitMap      application bitmap, could be one or combination of the following: \n
00553                                   - SL_NET_APP_HTTP_SERVER_ID
00554                                   - SL_NET_APP_DHCP_SERVER_ID
00555                                   - SL_NET_APP_MDNS_ID
00556 
00557         \return                   On error, negative number is returned
00558 
00559         \sa                       Stop one or more the above started applications using sl_NetAppStop
00560         \note                     This command activates the application for the current WLAN mode (AP or STA)
00561         \warning
00562         \par                 Example:
00563         \code
00564         For example: Starting internal HTTP server + DHCP server:
00565         sl_NetAppStart(SL_NET_APP_HTTP_SERVER_ID | SL_NET_APP_DHCP_SERVER_ID)
00566 
00567         \endcode
00568     */
00569 #if _SL_INCLUDE_FUNC(sl_NetAppStart)
00570     int16_t sl_NetAppStart(const uint32_t AppBitMap);
00571 #endif
00572     /*!
00573         \brief Stops a network application
00574 
00575         Gets and stops network application for the current WLAN mode
00576 
00577         \param[in] AppBitMap    application id, could be one of the following: \n
00578                                 - SL_NET_APP_HTTP_SERVER_ID
00579                                 - SL_NET_APP_DHCP_SERVER_ID
00580                                 - SL_NET_APP_MDNS_ID
00581 
00582         \return                 On error, negative number is returned
00583 
00584         \sa
00585         \note                This command disables the application for the current active WLAN mode (AP or STA)
00586         \warning
00587         \par                 Example:
00588         \code
00589 
00590         For example: Stopping internal HTTP server:
00591                              sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID);
00592 
00593         \endcode
00594     */
00595 #if _SL_INCLUDE_FUNC(sl_NetAppStop)
00596     int16_t sl_NetAppStop(const uint32_t AppBitMap);
00597 #endif
00598 
00599     /*!
00600         \brief Get host IP by name
00601 
00602         Obtain the IP Address of machine on network, by machine name.
00603 
00604         \param[in]  hostname        host name
00605         \param[in]  usNameLen       name length
00606         \param[out] out_ip_addr     This parameter is filled in with
00607                                     host IP address. In case that host name is not
00608                                     resolved, out_ip_addr is zero.
00609         \param[in]  family          protocol family
00610 
00611         \return                     On success, 0 is returned.
00612                                     On error, negative is returned
00613                                     SL_POOL_IS_EMPTY may be return in case there are no resources in the system
00614                                     In this case try again later or increase MAX_CONCURRENT_ACTIONS
00615                                     Possible DNS error codes:
00616                                     - SL_NET_APP_DNS_QUERY_NO_RESPONSE
00617                                     - SL_NET_APP_DNS_NO_SERVER
00618                                     - SL_NET_APP_DNS_QUERY_FAILED
00619                                     - SL_NET_APP_DNS_MALFORMED_PACKET
00620                                     - SL_NET_APP_DNS_MISMATCHED_RESPONSE
00621 
00622         \sa
00623         \note   Only one sl_NetAppDnsGetHostByName can be handled at a time.
00624                 Calling this API while the same command is called from another thread, may result
00625                 in one of the two scenarios:
00626                 1. The command will wait (internal) until the previous command finish, and then be executed.
00627                 2. There are not enough resources and POOL_IS_EMPTY error will return.
00628                 In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
00629                 again later to issue the command.
00630         \warning
00631         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 
00632         try to access the DNS and it will return the input address on the 'out_ip_addr' field 
00633         \par  Example:
00634         \code
00635         uint32_t DestinationIP;
00636         sl_NetAppDnsGetHostByName("www.google.com", strlen("www.google.com"), &DestinationIP,SL_AF_INET);
00637 
00638         Addr.sin_family = SL_AF_INET;
00639         Addr.sin_port = sl_Htons(80);
00640         Addr.sin_addr.s_addr = sl_Htonl(DestinationIP);
00641         AddrSize = sizeof(SlSockAddrIn_t);
00642         SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
00643         \endcode
00644     */
00645 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByName)
00646     int16_t sl_NetAppDnsGetHostByName(unsigned char * hostname, const uint16_t usNameLen, uint32_t*  out_ip_addr, const uint8_t family );
00647 #endif
00648 
00649     /*!
00650             \brief Return service attributes like IP address, port and text according to service name
00651             \par
00652             The user sets a service name Full/Part (see example below), and should get:
00653             - IP of service
00654             - The port of service
00655             - The text of service
00656 
00657             Hence it can make a connection to the specific service and use it.
00658             It is similar to get host by name method.
00659             It is done by a single shot query with PTR type on the service name.
00660                       The command that is sent is from constant parameters and variables parameters.
00661 
00662             \param[in]     pService                   Service name can be full or partial. \n
00663                                                       Example for full service name:
00664                                                       1. PC1._ipp._tcp.local
00665                                                       2. PC2_server._ftp._tcp.local \n
00666                                                       .
00667                                                       Example for partial service name:
00668                                                       1. _ipp._tcp.local
00669                                                       2. _ftp._tcp.local
00670 
00671             \param[in]    ServiceLen                  The length of the service name (in_pService).
00672             \param[in]    Family                      IPv4 or IPv6 (SL_AF_INET , SL_AF_INET6).
00673             \param[out]    pAddr                      Contains the IP address of the service.
00674             \param[out]    pPort                      Contains the port of the service.
00675             \param[out]    pTextLen                   Has 2 options. One as Input field and the other one as output:
00676                                                       - Input: \n
00677                                                       Contains the max length of the text that the user wants to get.\n
00678                                                       It means that if the text len of service is bigger that its value than
00679                                                       the text is cut to inout_TextLen value.
00680                                                       - Output: \n
00681                                                        Contain the length of the text that is returned. Can be full text or part of the text (see above).
00682 
00683             \param[out]   pOut_pText     Contains the text of the service full or partial
00684 
00685             \return       On success, zero is returned
00686                           SL_POOL_IS_EMPTY may be return in case there are no resources in the system
00687                           In this case try again later or increase MAX_CONCURRENT_ACTIONS
00688                           In case No service is found error SL_NET_APP_DNS_NO_ANSWER will be returned
00689 
00690             \note         The returns attributes belongs to the first service found.
00691                           There may be other services with the same service name that will response to the query.
00692                           The results of these responses are saved in the peer cache of the Device and should be read by another API.
00693 
00694                           Only one sl_NetAppDnsGetHostByService can be handled at a time.
00695                           Calling this API while the same command is called from another thread, may result
00696                           in one of the two scenarios:
00697                           1. The command will wait (internal) until the previous command finish, and then be executed.
00698                           2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
00699                           In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
00700                           again later to issue the command.
00701 
00702             \warning      Text length can be 120 bytes only
00703     */
00704 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByService)
00705     int32_t sl_NetAppDnsGetHostByService(unsigned char  *pServiceName, /*  string containing all (or only part): name + subtype + service */
00706                                          const uint8_t  ServiceLen,
00707                                          const uint8_t  Family,        /*  4-IPv4 , 16-IPv6  */
00708                                          uint32_t pAddr[],
00709                                          uint32_t *pPort,
00710                                          uint16_t *pTextLen,     /*  in: max len , out: actual len */
00711                                          unsigned char  *pText
00712                                         );
00713 
00714 #endif
00715 
00716     /*!
00717             \brief Get service List
00718             Insert into out pBuffer a list of peer's services that are the NWP.
00719             The list is in a form of service struct. The user should chose the type
00720             of the service struct like:
00721                 - Full service parameters with text.
00722                 - Full service parameters.
00723                 - Short service parameters (port and IP only) especially for tiny hosts.
00724 
00725             The different types of struct are made to give the
00726             Possibility to save memory in the host
00727 
00728 
00729             The user also chose how many max services to get and start point index
00730             NWP peer cache.
00731             For example:
00732                 1.    Get max of 3 full services from index 0.Up to 3 full services
00733                 from index 0 are inserted into pBuffer (services that are in indexes 0,1,2).
00734                 2.    Get max of 4 full services from index 3.Up to 4 full services
00735                 from index 3 are inserted into pBuffer (services that are in indexes 3,4,5,6).
00736                 3.    Get max of 2 int services from index 6.Up to 2 int services
00737                 from index 6 are inserted into pBuffer (services that are in indexes 6,7).
00738 
00739             See below - command parameters.
00740 
00741             \param[in] indexOffset - The start index in the peer cache that from it the first service is returned.
00742             \param[in] MaxServiceCount - The Max services that can be returned if existed or if not exceed the max index
00743                           in the peer cache
00744             \param[in] Flags - an ENUM number that means which service struct to use (means which types of service to fill)
00745                             - use SlNetAppGetFullServiceWithTextIpv4List_t
00746                             - use SlNetAppGetFullServiceIpv4List_t
00747                             - use SlNetAppGetShortServiceIpv4List_t
00748 
00749            \param[out]  Buffer - The Services are inserted into this buffer. In the struct form according to the bit that is set in the Flags
00750                           input parameter.
00751 
00752             \return    ServiceFoundCount - The number of the services that were inserted into the buffer. zero means no service is found
00753                         negative number means an error
00754             \sa           sl_NetAppMDNSRegisterService
00755             \note
00756             \warning
00757                         if the out pBuffer size is bigger than an RX packet(1480), than
00758                         an error is returned because there
00759                         is no place in the RX packet.
00760                         The size is a multiply of MaxServiceCount and size of service struct(that is set
00761                         according to flag value).
00762     */
00763 
00764 #if _SL_INCLUDE_FUNC(sl_NetAppGetServiceList)
00765     int16_t sl_NetAppGetServiceList(const uint8_t   IndexOffest,
00766                                     const uint8_t   MaxServiceCount,
00767                                     const uint8_t   Flags,
00768                                     int8_t   *pBuffer,
00769                                     const uint32_t  RxBufferLength
00770                                    );
00771 
00772 #endif
00773 
00774     /*!
00775             \brief Unregister mDNS service
00776             This function deletes the mDNS service from the mDNS package and the database.
00777 
00778             The mDNS service that is to be unregistered is a service that the application no longer wishes to provide. \n
00779             The service name should be the full service name according to RFC
00780             of the DNS-SD - meaning the value in name field in the SRV answer.
00781 
00782             Examples for service names:
00783             1. PC1._ipp._tcp.local
00784             2. PC2_server._ftp._tcp.local
00785 
00786             \param[in]    pServiceName            Full service name. \n
00787                                                     Example for service name:
00788                                                     1. PC1._ipp._tcp.local
00789                                                     2. PC2_server._ftp._tcp.local
00790             \param[in]    ServiceLen              The length of the service.
00791             \return    On success, zero is returned
00792             \sa          sl_NetAppMDNSRegisterService
00793             \note
00794             \warning
00795             The size of the service length should be smaller than 255.
00796     */
00797 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService)
00798     int16_t sl_NetAppMDNSUnRegisterService(const char *pServiceName, const uint8_t ServiceNameLen);
00799 #endif
00800 
00801     /*!
00802             \brief Register a new mDNS service
00803             \par
00804             This function registers a new mDNS service to the mDNS package and the DB.
00805 
00806             This registered service is a service offered by the application.
00807             The service name should be full service name according to RFC
00808             of the DNS-SD - meaning the value in name field in the SRV answer.
00809             Example for service name:
00810             1. PC1._ipp._tcp.local
00811             2. PC2_server._ftp._tcp.local
00812 
00813             If the option is_unique is set, mDNS probes the service name to make sure
00814             it is unique before starting to announce the service on the network.
00815             Instance is the instance portion of the service name.
00816 
00817             \param[in]  ServiceLen         The length of the service.
00818             \param[in]  TextLen            The length of the service should be smaller than 64.
00819             \param[in]  port               The port on this target host port.
00820             \param[in]  TTL                The TTL of the service
00821             \param[in]  Options            bitwise parameters: \n
00822                                            - bit 0  - service is unique (means that the service needs to be unique)
00823                                            - bit 31  - for internal use if the service should be added or deleted (set means ADD).
00824                                            - bit 1-30 for future.
00825 
00826             \param[in]    pServiceName              The service name.
00827                                            Example for service name: \n
00828                                                     1. PC1._ipp._tcp.local
00829                                                     2. PC2_server._ftp._tcp.local
00830 
00831             \param[in] pText                     The description of the service.
00832                                                     should be as mentioned in the RFC
00833                                                     (according to type of the service IPP,FTP...)
00834 
00835             \return     On success, zero is returned
00836                         Possible error codes:
00837                         - Maximum advertise services are already configured.
00838                                     Delete another existed service that is registered and then register again the new service
00839                         - Trying to register a service that is already exists
00840                         - Trying to delete service that does not existed
00841                         - Illegal service name according to the RFC
00842                         - Retry request
00843                         - Illegal length of one of the mDNS Set functions
00844                         - mDNS is not operational as the device has no IP.Connect the device to an AP to get an IP address.
00845                         - mDNS parameters error
00846                         - mDNS internal cache error
00847                         - mDNS internal error
00848                         - Adding a service is not allowed as it is already exist (duplicate service)
00849                         - mDNS is not running
00850                         - Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763
00851                         - List size buffer is bigger than internally allowed in the NWP (API get service list),
00852                          change the APIs� parameters to decrease the size of the list
00853 
00854 
00855             \sa              sl_NetAppMDNSUnRegisterService
00856 
00857             \warning      1) Temporary -  there is an allocation on stack of internal buffer.
00858                         Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. \n
00859                         It means that the sum of the text length and service name length cannot be bigger than
00860                         NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.\n
00861                         If it is - An error is returned. \n
00862                         2) According to now from certain constraints the variables parameters are set in the
00863                         attribute part (contain constant parameters)
00864     */
00865 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService)
00866     int16_t sl_NetAppMDNSRegisterService( const char*  pServiceName,
00867                                           const uint8_t         ServiceNameLen,
00868                                           const char*  pText,
00869                                           const uint8_t         TextLen,
00870                                           const uint16_t        Port,
00871                                           const uint32_t        TTL,
00872                                           uint32_t        Options);
00873 #endif
00874 
00875     /*!
00876         \brief send ICMP ECHO_REQUEST to network hosts
00877 
00878         Ping uses the ICMP protocol's mandatory ECHO_REQUEST
00879 
00880         \param[in]   pPingParams     Pointer to the ping request structure: \n
00881                                      - if flags parameter is set to 0, ping will report back once all requested pings are done (as defined by TotalNumberOfAttempts). \n
00882                                      - if flags parameter is set to 1, ping will report back after every ping, for TotalNumberOfAttempts.
00883                                      - 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.
00884                                      For stopping an ongoing ping activity, set parameters IP address to 0
00885 
00886         \param[in]   family          SL_AF_INET or  SL_AF_INET6
00887         \param[out]  pReport         Ping pReport
00888         \param[out]  pCallback       Callback function upon completion.
00889                                      If callback is NULL, the API is blocked until data arrives
00890 
00891 
00892         \return    On success, zero is returned. On error, -1 is returned
00893                    SL_POOL_IS_EMPTY may be return in case there are no resources in the system
00894                    In this case try again later or increase MAX_CONCURRENT_ACTIONS
00895 
00896         \sa       sl_NetAppPingReport
00897         \note      Only one sl_NetAppPingStart can be handled at a time.
00898                   Calling this API while the same command is called from another thread, may result
00899                       in one of the two scenarios:
00900                   1. The command will wait (internal) until the previous command finish, and then be executed.
00901                   2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
00902                   In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
00903                   again later to issue the command.
00904         \warning
00905         \par      Example:
00906         \code
00907 
00908         An example of sending 20 ping requests and reporting results to a callback routine when
00909                   all requests are sent:
00910 
00911                   // callback routine
00912                   void pingRes(SlPingReport_t* pReport)
00913                   {
00914                    // handle ping results
00915                   }
00916 
00917                   // ping activation
00918                   void PingTest()
00919                   {
00920                      SlPingReport_t report;
00921                      SlPingStartCommand_t pingCommand;
00922 
00923                      pingCommand.Ip = SL_IPV4_VAL(10,1,1,200);     // destination IP address is 10.1.1.200
00924                      pingCommand.PingSize = 150;                   // size of ping, in bytes
00925                      pingCommand.PingIntervalTime = 100;           // delay between pings, in milliseconds
00926                      pingCommand.PingRequestTimeout = 1000;        // timeout for every ping in milliseconds
00927                      pingCommand.TotalNumberOfAttempts = 20;       // max number of ping requests. 0 - forever
00928                      pingCommand.Flags = 0;                        // report only when finished
00929 
00930                      sl_NetAppPingStart( &pingCommand, SL_AF_INET, &report, pingRes ) ;
00931                  }
00932 
00933         \endcode
00934     */
00935 #if _SL_INCLUDE_FUNC(sl_NetAppPingStart)
00936     int16_t sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams, const uint8_t family,SlPingReport_t *pReport, const P_SL_DEV_PING_CALLBACK pPingCallback);
00937 #endif
00938 
00939     /*!
00940         \brief     Internal function for setting network application configurations
00941 
00942         \return    On success, zero is returned. On error, -1 is
00943                    returned
00944 
00945         \param[in] AppId          Application id, could be one of the following: \n
00946                                   - SL_NET_APP_HTTP_SERVER_ID
00947                                   - SL_NET_APP_DHCP_SERVER_ID
00948                                   - SL_NET_APP_MDNS_ID
00949                                   - SL_NET_APP_DEVICE_CONFIG_ID
00950 
00951         \param[in] SetOptions     set option, could be one of the following: \n
00952                                   - SL_NET_APP_DHCP_SERVER_ID
00953                                  - NETAPP_SET_DHCP_SRV_BASIC_OPT
00954                                  - SL_NET_APP_HTTP_SERVER_ID
00955                                  - NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
00956                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
00957                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
00958                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
00959                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
00960                                  - NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
00961                                  - SL_NET_APP_MDNS_ID
00962                                  - NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
00963                                  - NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
00964                                  - NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
00965                                  - SL_NET_APP_DEVICE_CONFIG_ID
00966                                  - NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
00967                                  - NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
00968 
00969 
00970         \param[in] OptionLen       option structure length
00971 
00972         \param[in] pOptionValues   pointer to the option structure
00973         \sa
00974         \note
00975         \warning
00976         \par
00977         \code
00978             Set DHCP Server (AP mode) parameters example:
00979 
00980             SlNetAppDhcpServerBasicOpt_t dhcpParams;
00981             uint8_t outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
00982             dhcpParams.lease_time      = 4096;                         // lease time (in seconds) of the IP Address
00983             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)
00984             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)
00985             sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID);                  // Stop DHCP server before settings
00986             sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, outLen, (uint8_t* )&dhcpParams);  // set parameters
00987             sl_NetAppStart(SL_NET_APP_DHCP_SERVER_ID);                 // Start DHCP server with new settings
00988         \endcode
00989         \code
00990             Set Device URN name example:
00991 
00992             Device name, maximum length of 33 characters
00993             Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
00994             In case no device URN name set, the default name is "mysimplelink"
00995             Allowed characters in device name are: 'a - z' , 'A - Z' , '0-9' and '-'
00996 
00997             uint8_t *my_device = "MY-SIMPLELINK-DEV";
00998             sl_NetAppSet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(my_device), (uint8_t *) my_device);
00999         \endcode
01000 
01001     */
01002 #if _SL_INCLUDE_FUNC(sl_NetAppSet)
01003     int32_t sl_NetAppSet(const uint8_t AppId, const uint8_t Option, const uint8_t OptionLen, const uint8_t *pOptionValue);
01004 #endif
01005 
01006     /*!
01007         \brief     Internal function for getting network applications configurations
01008 
01009         \return    On success, zero is returned. On error, -1 is
01010                    returned
01011 
01012         \param[in] AppId          Application id, could be one of the following: \n
01013                                   - SL_NET_APP_HTTP_SERVER_ID
01014                                   - SL_NET_APP_DHCP_SERVER_ID
01015                                   - SL_NET_APP_MDNS_ID
01016                                   - SL_NET_APP_DEVICE_CONFIG_ID
01017 
01018     \param[in] SetOptions     set option, could be one of the following: \n
01019                                  - SL_NET_APP_DHCP_SERVER_ID
01020                                  - NETAPP_SET_DHCP_SRV_BASIC_OPT
01021                                  - SL_NET_APP_HTTP_SERVER_ID
01022                                  - NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
01023                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
01024                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
01025                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
01026                                  - NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
01027                                  - NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
01028                                  - SL_NET_APP_MDNS_ID
01029                                  - NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
01030                                  - NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
01031                                  - NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
01032                                  - SL_NET_APP_DEVICE_CONFIG_ID
01033                                  - NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
01034                                  - NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
01035 
01036         \param[in] OptionLen     The length of the allocated memory as input, when the
01037                                             function complete, the value of this parameter would be
01038                                             the len that actually read from the device.
01039                                             If the device return length that is longer from the input
01040                                             value, the function will cut the end of the returned structure
01041                                             and will return ESMALLBUF
01042 
01043         \param[out] pValues      pointer to the option structure which will be filled with the response from the device
01044 
01045         \sa
01046         \note
01047         \warning
01048         \par
01049         \code
01050              Get DHCP Server parameters example:
01051 
01052              SlNetAppDhcpServerBasicOpt_t dhcpParams;
01053              uint8_t outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
01054              sl_NetAppGet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, &outLen, (uint8_t* )&dhcpParams);
01055 
01056              printf("DHCP Start IP %d.%d.%d.%d End IP %d.%d.%d.%d Lease time seconds %d\n",
01057                 SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,2),
01058                 SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,0),
01059                 SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,2),
01060                 SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,0),
01061                 dhcpParams.lease_time);
01062         \endcode
01063         \code
01064              Get Device URN name example:
01065              Maximum length of 33 characters of device name.
01066              Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
01067              in case no device URN name set, the default name is "mysimplelink"
01068 
01069              uint8_t my_device_name[35];
01070              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);
01071         \endcode
01072     */
01073 #if _SL_INCLUDE_FUNC(sl_NetAppGet)
01074     int32_t sl_NetAppGet(const uint8_t AppId, const uint8_t Option,uint8_t *pOptionLen, uint8_t *pOptionValue);
01075 #endif
01076 
01077 private:
01078 
01079     cc3100_driver           &_driver;
01080     cc3100_nonos            &_nonos;
01081 
01082 
01083 };//class
01084 
01085 /*****************************************************************************/
01086 /* Macro declarations                                                        */
01087 /*****************************************************************************/
01088 const uint8_t FLOW_CONT_MIN = 1;
01089 
01090 
01091 class cc3100_flowcont
01092 {
01093 
01094 public:
01095 
01096     cc3100_flowcont(cc3100_driver &driver, cc3100_nonos &nonos);
01097 
01098 
01099     ~cc3100_flowcont();
01100 
01101 #if 0
01102     /*****************************************************************************/
01103     /* Function prototypes                                                       */
01104     /*****************************************************************************/
01105     void _SlDrvFlowContInit(void);
01106     void _SlDrvFlowContDeinit(void);
01107 #endif
01108 
01109 private:
01110 
01111     cc3100_driver &_driver;
01112     cc3100_nonos  &_nonos;
01113 
01114 };//class
01115 }//namespace mbed_cc3100
01116 
01117 /*!
01118 
01119  Close the Doxygen group.
01120  @}
01121 
01122  */
01123 
01124 #endif    /*  __NETAPP_H__ */
01125 
01126