cc3100_Socket_Wifi_Server with Ethernet Interface not working

Dependencies:   EthernetInterface mbed-rtos mbed

Fork of cc3100_Test_Demo by David Fletcher

Committer:
dflet
Date:
Thu Mar 19 15:39:08 2015 +0000
Revision:
6:778b081f6a13
Updated to CC3100SDK1.1.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dflet 6:778b081f6a13 1 /*
dflet 6:778b081f6a13 2 * netapp.h - CC31xx/CC32xx Host Driver Implementation
dflet 6:778b081f6a13 3 *
dflet 6:778b081f6a13 4 * Copyright (C) 2014 Texas Instruments Incorporated - http://www.ti.com/
dflet 6:778b081f6a13 5 *
dflet 6:778b081f6a13 6 *
dflet 6:778b081f6a13 7 * Redistribution and use in source and binary forms, with or without
dflet 6:778b081f6a13 8 * modification, are permitted provided that the following conditions
dflet 6:778b081f6a13 9 * are met:
dflet 6:778b081f6a13 10 *
dflet 6:778b081f6a13 11 * Redistributions of source code must retain the above copyright
dflet 6:778b081f6a13 12 * notice, this list of conditions and the following disclaimer.
dflet 6:778b081f6a13 13 *
dflet 6:778b081f6a13 14 * Redistributions in binary form must reproduce the above copyright
dflet 6:778b081f6a13 15 * notice, this list of conditions and the following disclaimer in the
dflet 6:778b081f6a13 16 * documentation and/or other materials provided with the
dflet 6:778b081f6a13 17 * distribution.
dflet 6:778b081f6a13 18 *
dflet 6:778b081f6a13 19 * Neither the name of Texas Instruments Incorporated nor the names of
dflet 6:778b081f6a13 20 * its contributors may be used to endorse or promote products derived
dflet 6:778b081f6a13 21 * from this software without specific prior written permission.
dflet 6:778b081f6a13 22 *
dflet 6:778b081f6a13 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
dflet 6:778b081f6a13 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
dflet 6:778b081f6a13 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
dflet 6:778b081f6a13 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
dflet 6:778b081f6a13 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
dflet 6:778b081f6a13 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
dflet 6:778b081f6a13 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
dflet 6:778b081f6a13 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
dflet 6:778b081f6a13 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
dflet 6:778b081f6a13 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
dflet 6:778b081f6a13 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dflet 6:778b081f6a13 34 *
dflet 6:778b081f6a13 35 */
dflet 6:778b081f6a13 36
dflet 6:778b081f6a13 37 /*****************************************************************************/
dflet 6:778b081f6a13 38 /* Include files */
dflet 6:778b081f6a13 39 /*****************************************************************************/
dflet 6:778b081f6a13 40
dflet 6:778b081f6a13 41 #include "cc3100_simplelink.h"
dflet 6:778b081f6a13 42
dflet 6:778b081f6a13 43 #ifndef NETAPP_H_
dflet 6:778b081f6a13 44 #define NETAPP_H_
dflet 6:778b081f6a13 45
dflet 6:778b081f6a13 46 #include "cc3100_protocol.h"
dflet 6:778b081f6a13 47 #include "cc3100_nonos.h"
dflet 6:778b081f6a13 48
dflet 6:778b081f6a13 49 namespace mbed_cc3100 {
dflet 6:778b081f6a13 50
dflet 6:778b081f6a13 51 /*!
dflet 6:778b081f6a13 52
dflet 6:778b081f6a13 53 \addtogroup netapp
dflet 6:778b081f6a13 54 @{
dflet 6:778b081f6a13 55
dflet 6:778b081f6a13 56 */
dflet 6:778b081f6a13 57
dflet 6:778b081f6a13 58 /*****************************************************************************/
dflet 6:778b081f6a13 59 /* Macro declarations */
dflet 6:778b081f6a13 60 /*****************************************************************************/
dflet 6:778b081f6a13 61
dflet 6:778b081f6a13 62 /*ERROR code*/
dflet 6:778b081f6a13 63 const int16_t SL_ERROR_NETAPP_RX_BUFFER_LENGTH_ERROR = (-230);
dflet 6:778b081f6a13 64
dflet 6:778b081f6a13 65 /* Http Server interface */
dflet 6:778b081f6a13 66 const uint8_t MAX_INPUT_STRING = (64); /* because of WPA */
dflet 6:778b081f6a13 67
dflet 6:778b081f6a13 68 const uint8_t MAX_AUTH_NAME_LEN = (20);
dflet 6:778b081f6a13 69 const uint8_t MAX_AUTH_PASSWORD_LEN = (20);
dflet 6:778b081f6a13 70 const uint8_t MAX_AUTH_REALM_LEN = (20);
dflet 6:778b081f6a13 71
dflet 6:778b081f6a13 72 const uint8_t MAX_DEVICE_URN_LEN = (15+1);
dflet 6:778b081f6a13 73 const uint8_t MAX_DOMAIN_NAME_LEN = (24+1);
dflet 6:778b081f6a13 74
dflet 6:778b081f6a13 75 const uint8_t MAX_ACTION_LEN = (30);
dflet 6:778b081f6a13 76 /* Important: in case the max len is changed, make sure the struct sl_NetAppHttpServerSendToken_t in protocol.h is padded correctly! */
dflet 6:778b081f6a13 77 const uint8_t MAX_TOKEN_NAME_LEN = (20);
dflet 6:778b081f6a13 78 const uint8_t MAX_TOKEN_VALUE_LEN = MAX_INPUT_STRING;
dflet 6:778b081f6a13 79
dflet 6:778b081f6a13 80 const int16_t NETAPP_MAX_SERVICE_TEXT_SIZE = (256);
dflet 6:778b081f6a13 81 const uint8_t NETAPP_MAX_SERVICE_NAME_SIZE = (60);
dflet 6:778b081f6a13 82 const uint8_t NETAPP_MAX_SERVICE_HOST_NAME_SIZE = (64);
dflet 6:778b081f6a13 83
dflet 6:778b081f6a13 84
dflet 6:778b081f6a13 85 /* Server Responses */
dflet 6:778b081f6a13 86 const uint8_t SL_NETAPP_RESPONSE_NONE = (0);
dflet 6:778b081f6a13 87 const uint8_t SL_NETAPP_HTTPSETTOKENVALUE = (1);
dflet 6:778b081f6a13 88
dflet 6:778b081f6a13 89 const uint8_t SL_NETAPP_FAMILY_MASK = (0x80);
dflet 6:778b081f6a13 90
dflet 6:778b081f6a13 91 /* mDNS types */
dflet 6:778b081f6a13 92 const uint32_t SL_NET_APP_MASK_IPP_TYPE_OF_SERVICE = (0x00000001);
dflet 6:778b081f6a13 93 const uint32_t SL_NET_APP_MASK_DEVICE_INFO_TYPE_OF_SERVICE = (0x00000002);
dflet 6:778b081f6a13 94 const uint32_t SL_NET_APP_MASK_HTTP_TYPE_OF_SERVICE = (0x00000004);
dflet 6:778b081f6a13 95 const uint32_t SL_NET_APP_MASK_HTTPS_TYPE_OF_SERVICE = (0x00000008);
dflet 6:778b081f6a13 96 const uint32_t SL_NET_APP_MASK_WORKSATION_TYPE_OF_SERVICE = (0x00000010);
dflet 6:778b081f6a13 97 const uint32_t SL_NET_APP_MASK_GUID_TYPE_OF_SERVICE = (0x00000020);
dflet 6:778b081f6a13 98 const uint32_t SL_NET_APP_MASK_H323_TYPE_OF_SERVICE = (0x00000040);
dflet 6:778b081f6a13 99 const uint32_t SL_NET_APP_MASK_NTP_TYPE_OF_SERVICE = (0x00000080);
dflet 6:778b081f6a13 100 const uint32_t SL_NET_APP_MASK_OBJECITVE_TYPE_OF_SERVICE = (0x00000100);
dflet 6:778b081f6a13 101 const uint32_t SL_NET_APP_MASK_RDP_TYPE_OF_SERVICE = (0x00000200);
dflet 6:778b081f6a13 102 const uint32_t SL_NET_APP_MASK_REMOTE_TYPE_OF_SERVICE = (0x00000400);
dflet 6:778b081f6a13 103 const uint32_t SL_NET_APP_MASK_RTSP_TYPE_OF_SERVICE = (0x00000800);
dflet 6:778b081f6a13 104 const uint32_t SL_NET_APP_MASK_SIP_TYPE_OF_SERVICE = (0x00001000);
dflet 6:778b081f6a13 105 const uint32_t SL_NET_APP_MASK_SMB_TYPE_OF_SERVICE = (0x00002000);
dflet 6:778b081f6a13 106 const uint32_t SL_NET_APP_MASK_SOAP_TYPE_OF_SERVICE = (0x00004000);
dflet 6:778b081f6a13 107 const uint32_t SL_NET_APP_MASK_SSH_TYPE_OF_SERVICE = (0x00008000);
dflet 6:778b081f6a13 108 const uint32_t SL_NET_APP_MASK_TELNET_TYPE_OF_SERVICE = (0x00010000);
dflet 6:778b081f6a13 109 const uint32_t SL_NET_APP_MASK_TFTP_TYPE_OF_SERVICE = (0x00020000);
dflet 6:778b081f6a13 110 const uint32_t SL_NET_APP_MASK_XMPP_CLIENT_TYPE_OF_SERVICE = (0x00040000);
dflet 6:778b081f6a13 111 const uint32_t SL_NET_APP_MASK_RAOP_TYPE_OF_SERVICE = (0x00080000);
dflet 6:778b081f6a13 112 const uint32_t SL_NET_APP_MASK_ALL_TYPE_OF_SERVICE = (0xFFFFFFFF);
dflet 6:778b081f6a13 113
dflet 6:778b081f6a13 114 /********************************************************************************************************/
dflet 6:778b081f6a13 115 /* sl_NetAppDnsGetHostByName error codes */
dflet 6:778b081f6a13 116
dflet 6:778b081f6a13 117 const int16_t SL_NET_APP_DNS_QUERY_NO_RESPONSE = (-159); /* DNS query failed, no response */
dflet 6:778b081f6a13 118 const int16_t SL_NET_APP_DNS_NO_SERVER = (-161); /* No DNS server was specified */
dflet 6:778b081f6a13 119 const int16_t SL_NET_APP_DNS_PARAM_ERROR = (-162); /* mDNS parameters error */
dflet 6:778b081f6a13 120 const int16_t SL_NET_APP_DNS_QUERY_FAILED = (-163); /* DNS query failed; no DNS server sent an 'answer' */
dflet 6:778b081f6a13 121 const int16_t SL_NET_APP_DNS_INTERNAL_1 = (-164);
dflet 6:778b081f6a13 122 const int16_t SL_NET_APP_DNS_INTERNAL_2 = (-165);
dflet 6:778b081f6a13 123 const int16_t SL_NET_APP_DNS_MALFORMED_PACKET = (-166); /* Improperly formed or corrupted DNS packet received */
dflet 6:778b081f6a13 124 const int16_t SL_NET_APP_DNS_INTERNAL_3 = (-167);
dflet 6:778b081f6a13 125 const int16_t SL_NET_APP_DNS_INTERNAL_4 = (-168);
dflet 6:778b081f6a13 126 const int16_t SL_NET_APP_DNS_INTERNAL_5 = (-169);
dflet 6:778b081f6a13 127 const int16_t SL_NET_APP_DNS_INTERNAL_6 = (-170);
dflet 6:778b081f6a13 128 const int16_t SL_NET_APP_DNS_INTERNAL_7 = (-171);
dflet 6:778b081f6a13 129 const int16_t SL_NET_APP_DNS_INTERNAL_8 = (-172);
dflet 6:778b081f6a13 130 const int16_t SL_NET_APP_DNS_INTERNAL_9 = (-173);
dflet 6:778b081f6a13 131 const int16_t SL_NET_APP_DNS_MISMATCHED_RESPONSE = (-174); /* Server response type does not match the query request*/
dflet 6:778b081f6a13 132 const int16_t SL_NET_APP_DNS_INTERNAL_10 = (-175);
dflet 6:778b081f6a13 133 const int16_t SL_NET_APP_DNS_INTERNAL_11 = (-176);
dflet 6:778b081f6a13 134 const int16_t SL_NET_APP_DNS_NO_ANSWER = (-177); /* No response for one-shot query */
dflet 6:778b081f6a13 135 const int16_t SL_NET_APP_DNS_NO_KNOWN_ANSWER = (-178); /* No known answer for query */
dflet 6:778b081f6a13 136 const int16_t SL_NET_APP_DNS_NAME_MISMATCH = (-179); /* Illegal service name according to the RFC */
dflet 6:778b081f6a13 137 const int16_t SL_NET_APP_DNS_NOT_STARTED = (-180); /* mDNS is not running */
dflet 6:778b081f6a13 138 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 */
dflet 6:778b081f6a13 139 const int16_t SL_NET_APP_DNS_NO_MORE_ENTRIES = (-182); /* No more entries be found. */
dflet 6:778b081f6a13 140
dflet 6:778b081f6a13 141 const int16_t SL_NET_APP_DNS_MAX_SERVICES_ERROR = (-200); /* Maximum advertise services are already configured */
dflet 6:778b081f6a13 142 const int16_t SL_NET_APP_DNS_IDENTICAL_SERVICES_ERROR = (-201); /* Trying to register a service that is already exists */
dflet 6:778b081f6a13 143 const int16_t SL_NET_APP_DNS_NOT_EXISTED_SERVICE_ERROR = (-203); /* Trying to delete service that does not existed */
dflet 6:778b081f6a13 144 const int16_t SL_NET_APP_DNS_ERROR_SERVICE_NAME_ERROR = (-204); /* Illegal service name according to the RFC */
dflet 6:778b081f6a13 145 const int16_t SL_NET_APP_DNS_RX_PACKET_ALLOCATION_ERROR = (-205); /* Retry request */
dflet 6:778b081f6a13 146 const int16_t SL_NET_APP_DNS_BUFFER_SIZE_ERROR = (-206); /* List size buffer is bigger than internally allowed in the NWP */
dflet 6:778b081f6a13 147 const int16_t SL_NET_APP_DNS_NET_APP_SET_ERROR = (-207); /* Illegal length of one of the mDNS Set functions */
dflet 6:778b081f6a13 148 const int16_t SL_NET_APP_DNS_GET_SERVICE_LIST_FLAG_ERROR = (-208);
dflet 6:778b081f6a13 149 const int16_t SL_NET_APP_DNS_NO_CONFIGURATION_ERROR = (-209);
dflet 6:778b081f6a13 150
dflet 6:778b081f6a13 151 /* Set Dev name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN) */
dflet 6:778b081f6a13 152 const int16_t SL_ERROR_DEVICE_NAME_LEN_ERR = (-117);
dflet 6:778b081f6a13 153 const int16_t SL_ERROR_DEVICE_NAME_INVALID = (-118);
dflet 6:778b081f6a13 154 /* Set domain name error codes (NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME) */
dflet 6:778b081f6a13 155 const int16_t SL_ERROR_DOMAIN_NAME_LEN_ERR = (-119);
dflet 6:778b081f6a13 156 const int16_t SL_ERROR_DOMAIN_NAME_INVALID = (-120);
dflet 6:778b081f6a13 157
dflet 6:778b081f6a13 158 /********************************************************************************************************/
dflet 6:778b081f6a13 159
dflet 6:778b081f6a13 160 /* NetApp application IDs */
dflet 6:778b081f6a13 161 const uint8_t SL_NET_APP_HTTP_SERVER_ID = (1);
dflet 6:778b081f6a13 162 const uint8_t SL_NET_APP_DHCP_SERVER_ID = (2);
dflet 6:778b081f6a13 163 const uint8_t SL_NET_APP_MDNS_ID = (4);
dflet 6:778b081f6a13 164 const uint8_t SL_NET_APP_DNS_SERVER_ID = (8);
dflet 6:778b081f6a13 165 const uint8_t SL_NET_APP_DEVICE_CONFIG_ID = (16);
dflet 6:778b081f6a13 166 /* NetApp application set/get options */
dflet 6:778b081f6a13 167 const uint8_t NETAPP_SET_DHCP_SRV_BASIC_OPT = (0);
dflet 6:778b081f6a13 168 /* HTTP server set/get options */
dflet 6:778b081f6a13 169 const uint8_t NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER = (0);
dflet 6:778b081f6a13 170 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK = (1);
dflet 6:778b081f6a13 171 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_NAME = (2);
dflet 6:778b081f6a13 172 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD = (3);
dflet 6:778b081f6a13 173 const uint8_t NETAPP_SET_GET_HTTP_OPT_AUTH_REALM = (4);
dflet 6:778b081f6a13 174 const uint8_t NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS = (5);
dflet 6:778b081f6a13 175
dflet 6:778b081f6a13 176 const uint8_t NETAPP_SET_GET_MDNS_CONT_QUERY_OPT = (1);
dflet 6:778b081f6a13 177 const uint8_t NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT = (2);
dflet 6:778b081f6a13 178 const uint8_t NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT = (3);
dflet 6:778b081f6a13 179
dflet 6:778b081f6a13 180 /* DNS server set/get options */
dflet 6:778b081f6a13 181 const uint8_t NETAPP_SET_GET_DNS_OPT_DOMAIN_NAME = (0);
dflet 6:778b081f6a13 182
dflet 6:778b081f6a13 183 /* Device Config set/get options */
dflet 6:778b081f6a13 184 const uint8_t NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN = (0);
dflet 6:778b081f6a13 185 const uint8_t NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME = (1);
dflet 6:778b081f6a13 186
dflet 6:778b081f6a13 187
dflet 6:778b081f6a13 188 /*****************************************************************************/
dflet 6:778b081f6a13 189 /* Structure/Enum declarations */
dflet 6:778b081f6a13 190 /*****************************************************************************/
dflet 6:778b081f6a13 191 /*
dflet 6:778b081f6a13 192 * The below structure depict the constant parameters that are returned in the Async event answer
dflet 6:778b081f6a13 193 * according to command/API sl_DnsGetHostByService for IPv4 and IPv6.
dflet 6:778b081f6a13 194 *
dflet 6:778b081f6a13 195 1Status - The status of the response.
dflet 6:778b081f6a13 196 2.Address - Contains the IP address of the service.
dflet 6:778b081f6a13 197 3.Port - Contains the port of the service.
dflet 6:778b081f6a13 198 4.TextLen - Contains the max length of the text that the user wants to get.
dflet 6:778b081f6a13 199 it means that if the test of service is bigger that its value than
dflet 6:778b081f6a13 200 the text is cut to inout_TextLen value.
dflet 6:778b081f6a13 201 Output: Contain the length of the text that is returned. Can be full text or part
dflet 6:778b081f6a13 202 of the text (see above).
dflet 6:778b081f6a13 203
dflet 6:778b081f6a13 204 *
dflet 6:778b081f6a13 205 */
dflet 6:778b081f6a13 206 typedef struct {
dflet 6:778b081f6a13 207 uint16_t Status;
dflet 6:778b081f6a13 208 uint16_t TextLen;
dflet 6:778b081f6a13 209 uint32_t Port;
dflet 6:778b081f6a13 210 uint32_t Address;
dflet 6:778b081f6a13 211 } _GetHostByServiceIPv4AsyncResponse_t;
dflet 6:778b081f6a13 212
dflet 6:778b081f6a13 213 /*
dflet 6:778b081f6a13 214 * The below struct contains pointers to the output parameters that the user gives
dflet 6:778b081f6a13 215 *
dflet 6:778b081f6a13 216 */
dflet 6:778b081f6a13 217 typedef struct {
dflet 6:778b081f6a13 218 int16_t Status;
dflet 6:778b081f6a13 219 uint32_t *out_pAddr;
dflet 6:778b081f6a13 220 uint32_t *out_pPort;
dflet 6:778b081f6a13 221 uint16_t *inout_TextLen; // in: max len , out: actual len
dflet 6:778b081f6a13 222 unsigned char *out_pText;
dflet 6:778b081f6a13 223 } _GetHostByServiceAsyncResponse_t;
dflet 6:778b081f6a13 224
dflet 6:778b081f6a13 225 typedef struct {
dflet 6:778b081f6a13 226 uint32_t PacketsSent;
dflet 6:778b081f6a13 227 uint32_t PacketsReceived;
dflet 6:778b081f6a13 228 uint16_t MinRoundTime;
dflet 6:778b081f6a13 229 uint16_t MaxRoundTime;
dflet 6:778b081f6a13 230 uint16_t AvgRoundTime;
dflet 6:778b081f6a13 231 uint32_t TestTime;
dflet 6:778b081f6a13 232 } SlPingReport_t;
dflet 6:778b081f6a13 233
dflet 6:778b081f6a13 234 typedef struct {
dflet 6:778b081f6a13 235 uint32_t PingIntervalTime; /* delay between pings, in milliseconds */
dflet 6:778b081f6a13 236 uint16_t PingSize; /* ping packet size in bytes */
dflet 6:778b081f6a13 237 uint16_t PingRequestTimeout; /* timeout time for every ping in milliseconds */
dflet 6:778b081f6a13 238 uint32_t TotalNumberOfAttempts; /* max number of ping requests. 0 - forever */
dflet 6:778b081f6a13 239 uint32_t Flags; /* flag - 0 report only when finished, 1 - return response for every ping, 2 - stop after 1 successful ping. */
dflet 6:778b081f6a13 240 uint32_t Ip; /* IPv4 address or IPv6 first 4 bytes */
dflet 6:778b081f6a13 241 uint32_t Ip1OrPaadding;
dflet 6:778b081f6a13 242 uint32_t Ip2OrPaadding;
dflet 6:778b081f6a13 243 uint32_t Ip3OrPaadding;
dflet 6:778b081f6a13 244 } SlPingStartCommand_t;
dflet 6:778b081f6a13 245
dflet 6:778b081f6a13 246 typedef struct _slHttpServerString_t {
dflet 6:778b081f6a13 247 uint8_t len;
dflet 6:778b081f6a13 248 uint8_t *data;
dflet 6:778b081f6a13 249 } slHttpServerString_t;
dflet 6:778b081f6a13 250
dflet 6:778b081f6a13 251 typedef struct _slHttpServerData_t {
dflet 6:778b081f6a13 252 uint8_t value_len;
dflet 6:778b081f6a13 253 uint8_t name_len;
dflet 6:778b081f6a13 254 uint8_t *token_value;
dflet 6:778b081f6a13 255 uint8_t *token_name;
dflet 6:778b081f6a13 256 } slHttpServerData_t;
dflet 6:778b081f6a13 257
dflet 6:778b081f6a13 258 typedef struct _slHttpServerPostData_t {
dflet 6:778b081f6a13 259 slHttpServerString_t action;
dflet 6:778b081f6a13 260 slHttpServerString_t token_name;
dflet 6:778b081f6a13 261 slHttpServerString_t token_value;
dflet 6:778b081f6a13 262 } slHttpServerPostData_t;
dflet 6:778b081f6a13 263
dflet 6:778b081f6a13 264 typedef union {
dflet 6:778b081f6a13 265 slHttpServerString_t httpTokenName; /* SL_NETAPP_HTTPGETTOKENVALUE */
dflet 6:778b081f6a13 266 slHttpServerPostData_t httpPostData; /* SL_NETAPP_HTTPPOSTTOKENVALUE */
dflet 6:778b081f6a13 267 } SlHttpServerEventData_u;
dflet 6:778b081f6a13 268
dflet 6:778b081f6a13 269 typedef union {
dflet 6:778b081f6a13 270 slHttpServerString_t token_value;
dflet 6:778b081f6a13 271 } SlHttpServerResponsedata_u;
dflet 6:778b081f6a13 272
dflet 6:778b081f6a13 273 typedef struct {
dflet 6:778b081f6a13 274 uint32_t Event;
dflet 6:778b081f6a13 275 SlHttpServerEventData_u EventData;
dflet 6:778b081f6a13 276 } SlHttpServerEvent_t;
dflet 6:778b081f6a13 277
dflet 6:778b081f6a13 278 typedef struct {
dflet 6:778b081f6a13 279 uint32_t Response;
dflet 6:778b081f6a13 280 SlHttpServerResponsedata_u ResponseData;
dflet 6:778b081f6a13 281 } SlHttpServerResponse_t;
dflet 6:778b081f6a13 282
dflet 6:778b081f6a13 283
dflet 6:778b081f6a13 284 typedef struct {
dflet 6:778b081f6a13 285 uint32_t lease_time;
dflet 6:778b081f6a13 286 uint32_t ipv4_addr_start;
dflet 6:778b081f6a13 287 uint32_t ipv4_addr_last;
dflet 6:778b081f6a13 288 } SlNetAppDhcpServerBasicOpt_t;
dflet 6:778b081f6a13 289
dflet 6:778b081f6a13 290 /*mDNS parameters*/
dflet 6:778b081f6a13 291 typedef enum {
dflet 6:778b081f6a13 292 SL_NET_APP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE = 1,
dflet 6:778b081f6a13 293 SL_NET_APP_FULL_SERVICE_IPV4_TYPE,
dflet 6:778b081f6a13 294 SL_NET_APP_SHORT_SERVICE_IPV4_TYPE
dflet 6:778b081f6a13 295
dflet 6:778b081f6a13 296 } SlNetAppGetServiceListType_e;
dflet 6:778b081f6a13 297
dflet 6:778b081f6a13 298 typedef struct {
dflet 6:778b081f6a13 299 uint32_t service_ipv4;
dflet 6:778b081f6a13 300 uint16_t service_port;
dflet 6:778b081f6a13 301 uint16_t Reserved;
dflet 6:778b081f6a13 302 } SlNetAppGetShortServiceIpv4List_t;
dflet 6:778b081f6a13 303
dflet 6:778b081f6a13 304 typedef struct {
dflet 6:778b081f6a13 305 uint32_t service_ipv4;
dflet 6:778b081f6a13 306 uint16_t service_port;
dflet 6:778b081f6a13 307 uint16_t Reserved;
dflet 6:778b081f6a13 308 uint8_t service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
dflet 6:778b081f6a13 309 uint8_t service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
dflet 6:778b081f6a13 310 } SlNetAppGetFullServiceIpv4List_t;
dflet 6:778b081f6a13 311
dflet 6:778b081f6a13 312 typedef struct {
dflet 6:778b081f6a13 313 uint32_t service_ipv4;
dflet 6:778b081f6a13 314 uint16_t service_port;
dflet 6:778b081f6a13 315 uint16_t Reserved;
dflet 6:778b081f6a13 316 uint8_t service_name[NETAPP_MAX_SERVICE_NAME_SIZE];
dflet 6:778b081f6a13 317 uint8_t service_host[NETAPP_MAX_SERVICE_HOST_NAME_SIZE];
dflet 6:778b081f6a13 318 uint8_t service_text[NETAPP_MAX_SERVICE_TEXT_SIZE];
dflet 6:778b081f6a13 319 } SlNetAppGetFullServiceWithTextIpv4List_t;
dflet 6:778b081f6a13 320
dflet 6:778b081f6a13 321 typedef struct {
dflet 6:778b081f6a13 322 /*The below parameters are used to configure the advertise times and interval
dflet 6:778b081f6a13 323 For example:
dflet 6:778b081f6a13 324 If:
dflet 6:778b081f6a13 325 Period is set to T
dflet 6:778b081f6a13 326 Repetitions are set to P
dflet 6:778b081f6a13 327 Telescopic factor is K=2
dflet 6:778b081f6a13 328 The transmission shall be:
dflet 6:778b081f6a13 329 advertise P times
dflet 6:778b081f6a13 330 wait T
dflet 6:778b081f6a13 331 advertise P times
dflet 6:778b081f6a13 332 wait 4 * T
dflet 6:778b081f6a13 333 advertise P time
dflet 6:778b081f6a13 334 wait 16 * T ... (till max time reached / configuration changed / query issued)
dflet 6:778b081f6a13 335 */
dflet 6:778b081f6a13 336 uint32_t t; /* Number of ticks for the initial period. Default is 100 ticks for 1 second. */
dflet 6:778b081f6a13 337 uint32_t p; /* Number of repetitions. Default value is 1 */
dflet 6:778b081f6a13 338 uint32_t k; /* Telescopic factor. Default value is 2. */
dflet 6:778b081f6a13 339 uint32_t RetransInterval;/* Announcing retransmission interval */
dflet 6:778b081f6a13 340 uint32_t Maxinterval; /* Announcing max period interval */
dflet 6:778b081f6a13 341 uint32_t max_time; /* Announcing max time */
dflet 6:778b081f6a13 342 } SlNetAppServiceAdvertiseTimingParameters_t;
dflet 6:778b081f6a13 343
dflet 6:778b081f6a13 344 /*****************************************************************************/
dflet 6:778b081f6a13 345 /* Types declarations */
dflet 6:778b081f6a13 346 /*****************************************************************************/
dflet 6:778b081f6a13 347 typedef void (*P_SL_DEV_PING_CALLBACK)(SlPingReport_t*);
dflet 6:778b081f6a13 348 extern P_SL_DEV_PING_CALLBACK pPingCallBackFunc;
dflet 6:778b081f6a13 349
dflet 6:778b081f6a13 350 /*****************************************************************************************
dflet 6:778b081f6a13 351 * NETAPP structs
dflet 6:778b081f6a13 352 ******************************************************************************************/
dflet 6:778b081f6a13 353
dflet 6:778b081f6a13 354
dflet 6:778b081f6a13 355 typedef _BasicResponse_t _NetAppStartStopResponse_t;
dflet 6:778b081f6a13 356
dflet 6:778b081f6a13 357 typedef struct {
dflet 6:778b081f6a13 358 uint32_t appId;
dflet 6:778b081f6a13 359 } _NetAppStartStopCommand_t;
dflet 6:778b081f6a13 360
dflet 6:778b081f6a13 361 typedef struct {
dflet 6:778b081f6a13 362 uint16_t Status;
dflet 6:778b081f6a13 363 uint16_t AppId;
dflet 6:778b081f6a13 364 uint16_t ConfigOpt;
dflet 6:778b081f6a13 365 uint16_t ConfigLen;
dflet 6:778b081f6a13 366 } _NetAppSetGet_t;
dflet 6:778b081f6a13 367 typedef struct {
dflet 6:778b081f6a13 368 uint16_t port_number;
dflet 6:778b081f6a13 369 } _NetAppHttpServerGetSet_port_num_t;
dflet 6:778b081f6a13 370
dflet 6:778b081f6a13 371 typedef struct {
dflet 6:778b081f6a13 372 uint8_t auth_enable;
dflet 6:778b081f6a13 373 } _NetAppHttpServerGetSet_auth_enable_t;
dflet 6:778b081f6a13 374
dflet 6:778b081f6a13 375 typedef struct _sl_NetAppHttpServerGetToken_t {
dflet 6:778b081f6a13 376 uint8_t token_name_len;
dflet 6:778b081f6a13 377 uint8_t padd1;
dflet 6:778b081f6a13 378 uint16_t padd2;
dflet 6:778b081f6a13 379 } sl_NetAppHttpServerGetToken_t;
dflet 6:778b081f6a13 380
dflet 6:778b081f6a13 381 typedef struct _sl_NetAppHttpServerSendToken_t {
dflet 6:778b081f6a13 382 uint8_t token_value_len;
dflet 6:778b081f6a13 383 uint8_t token_name_len;
dflet 6:778b081f6a13 384 uint8_t token_name[MAX_TOKEN_NAME_LEN];
dflet 6:778b081f6a13 385 uint16_t padd;
dflet 6:778b081f6a13 386 } sl_NetAppHttpServerSendToken_t;
dflet 6:778b081f6a13 387
dflet 6:778b081f6a13 388 typedef struct _sl_NetAppHttpServerPostToken_t {
dflet 6:778b081f6a13 389 uint8_t post_action_len;
dflet 6:778b081f6a13 390 uint8_t token_name_len;
dflet 6:778b081f6a13 391 uint8_t token_value_len;
dflet 6:778b081f6a13 392 uint8_t padding;
dflet 6:778b081f6a13 393 } sl_NetAppHttpServerPostToken_t;
dflet 6:778b081f6a13 394
dflet 6:778b081f6a13 395
dflet 6:778b081f6a13 396 typedef struct {
dflet 6:778b081f6a13 397 uint16_t Len;
dflet 6:778b081f6a13 398 uint8_t family;
dflet 6:778b081f6a13 399 uint8_t padding;
dflet 6:778b081f6a13 400 } _GetHostByNameCommand_t;
dflet 6:778b081f6a13 401
dflet 6:778b081f6a13 402 typedef struct {
dflet 6:778b081f6a13 403 uint16_t status;
dflet 6:778b081f6a13 404 uint16_t padding;
dflet 6:778b081f6a13 405 uint32_t ip0;
dflet 6:778b081f6a13 406 uint32_t ip1;
dflet 6:778b081f6a13 407 uint32_t ip2;
dflet 6:778b081f6a13 408 uint32_t ip3;
dflet 6:778b081f6a13 409 } _GetHostByNameIPv6AsyncResponse_t;
dflet 6:778b081f6a13 410
dflet 6:778b081f6a13 411 typedef struct {
dflet 6:778b081f6a13 412 uint16_t status;
dflet 6:778b081f6a13 413 uint8_t padding1;
dflet 6:778b081f6a13 414 uint8_t padding2;
dflet 6:778b081f6a13 415 uint32_t ip0;
dflet 6:778b081f6a13 416 } _GetHostByNameIPv4AsyncResponse_t;
dflet 6:778b081f6a13 417
dflet 6:778b081f6a13 418 typedef enum {
dflet 6:778b081f6a13 419 CTST_BSD_UDP_TX,
dflet 6:778b081f6a13 420 CTST_BSD_UDP_RX,
dflet 6:778b081f6a13 421 CTST_BSD_TCP_TX,
dflet 6:778b081f6a13 422 CTST_BSD_TCP_RX,
dflet 6:778b081f6a13 423 CTST_BSD_TCP_SERVER_BI_DIR,
dflet 6:778b081f6a13 424 CTST_BSD_TCP_CLIENT_BI_DIR,
dflet 6:778b081f6a13 425 CTST_BSD_UDP_BI_DIR,
dflet 6:778b081f6a13 426 CTST_BSD_RAW_TX,
dflet 6:778b081f6a13 427 CTST_BSD_RAW_RX,
dflet 6:778b081f6a13 428 CTST_BSD_RAW_BI_DIR,
dflet 6:778b081f6a13 429 CTST_BSD_SECURED_TCP_TX,
dflet 6:778b081f6a13 430 CTST_BSD_SECURED_TCP_RX,
dflet 6:778b081f6a13 431 CTST_BSD_SECURED_TCP_SERVER_BI_DIR,
dflet 6:778b081f6a13 432 CTST_BSD_SECURED_TCP_CLIENT_BI_DIR
dflet 6:778b081f6a13 433 } CommTest_e;
dflet 6:778b081f6a13 434
dflet 6:778b081f6a13 435 typedef struct _sl_protocol_CtestStartCommand_t {
dflet 6:778b081f6a13 436 uint32_t Test;
dflet 6:778b081f6a13 437 uint16_t DestPort;
dflet 6:778b081f6a13 438 uint16_t SrcPort;
dflet 6:778b081f6a13 439 uint32_t DestAddr[4];
dflet 6:778b081f6a13 440 uint32_t PayloadSize;
dflet 6:778b081f6a13 441 uint32_t timeout;
dflet 6:778b081f6a13 442 uint32_t csEnabled;
dflet 6:778b081f6a13 443 uint32_t secure;
dflet 6:778b081f6a13 444 uint32_t rawProtocol;
dflet 6:778b081f6a13 445 uint8_t reserved1[4];
dflet 6:778b081f6a13 446 } _CtestStartCommand_t;
dflet 6:778b081f6a13 447
dflet 6:778b081f6a13 448 typedef struct {
dflet 6:778b081f6a13 449 uint8_t test;
dflet 6:778b081f6a13 450 uint8_t socket;
dflet 6:778b081f6a13 451 int16_t status;
dflet 6:778b081f6a13 452 uint32_t startTime;
dflet 6:778b081f6a13 453 uint32_t endTime;
dflet 6:778b081f6a13 454 uint16_t txKbitsSec;
dflet 6:778b081f6a13 455 uint16_t rxKbitsSec;
dflet 6:778b081f6a13 456 uint32_t outOfOrderPackets;
dflet 6:778b081f6a13 457 uint32_t missedPackets;
dflet 6:778b081f6a13 458 int16_t token;
dflet 6:778b081f6a13 459 } _CtestAsyncResponse_t;
dflet 6:778b081f6a13 460
dflet 6:778b081f6a13 461 typedef struct {
dflet 6:778b081f6a13 462 uint32_t pingIntervalTime;
dflet 6:778b081f6a13 463 uint16_t PingSize;
dflet 6:778b081f6a13 464 uint16_t pingRequestTimeout;
dflet 6:778b081f6a13 465 uint32_t totalNumberOfAttempts;
dflet 6:778b081f6a13 466 uint32_t flags;
dflet 6:778b081f6a13 467 uint32_t ip0;
dflet 6:778b081f6a13 468 uint32_t ip1OrPaadding;
dflet 6:778b081f6a13 469 uint32_t ip2OrPaadding;
dflet 6:778b081f6a13 470 uint32_t ip3OrPaadding;
dflet 6:778b081f6a13 471 } _PingStartCommand_t;
dflet 6:778b081f6a13 472
dflet 6:778b081f6a13 473 typedef struct {
dflet 6:778b081f6a13 474 uint16_t status;
dflet 6:778b081f6a13 475 uint16_t rttMin;
dflet 6:778b081f6a13 476 uint16_t rttMax;
dflet 6:778b081f6a13 477 uint16_t rttAvg;
dflet 6:778b081f6a13 478 uint32_t numSuccsessPings;
dflet 6:778b081f6a13 479 uint32_t numSendsPings;
dflet 6:778b081f6a13 480 uint32_t testTime;
dflet 6:778b081f6a13 481 } _PingReportResponse_t;
dflet 6:778b081f6a13 482
dflet 6:778b081f6a13 483
dflet 6:778b081f6a13 484 typedef struct {
dflet 6:778b081f6a13 485 uint32_t ip;
dflet 6:778b081f6a13 486 uint32_t gateway;
dflet 6:778b081f6a13 487 uint32_t dns;
dflet 6:778b081f6a13 488 } _IpV4AcquiredAsync_t;
dflet 6:778b081f6a13 489
dflet 6:778b081f6a13 490
dflet 6:778b081f6a13 491 typedef enum {
dflet 6:778b081f6a13 492 ACQUIRED_IPV6_LOCAL = 1,
dflet 6:778b081f6a13 493 ACQUIRED_IPV6_GLOBAL
dflet 6:778b081f6a13 494 } IpV6AcquiredType_e;
dflet 6:778b081f6a13 495
dflet 6:778b081f6a13 496
dflet 6:778b081f6a13 497 typedef struct {
dflet 6:778b081f6a13 498 uint32_t type;
dflet 6:778b081f6a13 499 uint32_t ip[4];
dflet 6:778b081f6a13 500 uint32_t gateway[4];
dflet 6:778b081f6a13 501 uint32_t dns[4];
dflet 6:778b081f6a13 502 } _IpV6AcquiredAsync_t;
dflet 6:778b081f6a13 503
dflet 6:778b081f6a13 504
dflet 6:778b081f6a13 505 typedef union {
dflet 6:778b081f6a13 506 _SocketCommand_t EventMask;
dflet 6:778b081f6a13 507 _sendRecvCommand_t DeviceInit;
dflet 6:778b081f6a13 508 } _device_commands_t;
dflet 6:778b081f6a13 509
dflet 6:778b081f6a13 510
dflet 6:778b081f6a13 511 class cc3100_netapp
dflet 6:778b081f6a13 512 {
dflet 6:778b081f6a13 513
dflet 6:778b081f6a13 514 public:
dflet 6:778b081f6a13 515
dflet 6:778b081f6a13 516 cc3100_netapp(cc3100_driver &driver, cc3100_nonos &nonos);
dflet 6:778b081f6a13 517
dflet 6:778b081f6a13 518 ~cc3100_netapp();
dflet 6:778b081f6a13 519
dflet 6:778b081f6a13 520 /*****************************************************************************/
dflet 6:778b081f6a13 521 /* Functions prototypes */
dflet 6:778b081f6a13 522 /*****************************************************************************/
dflet 6:778b081f6a13 523 int16_t sl_NetAppMDNSRegisterUnregisterService(const char* pServiceName,
dflet 6:778b081f6a13 524 const uint8_t ServiceNameLen,
dflet 6:778b081f6a13 525 const char* pText,
dflet 6:778b081f6a13 526 const uint8_t TextLen,
dflet 6:778b081f6a13 527 const uint16_t Port,
dflet 6:778b081f6a13 528 const uint32_t TTL,
dflet 6:778b081f6a13 529 const uint32_t Options);
dflet 6:778b081f6a13 530
dflet 6:778b081f6a13 531 void _sl_HandleAsync_DnsGetHostByAddr(void *pVoidBuf);
dflet 6:778b081f6a13 532
dflet 6:778b081f6a13 533 void CopyPingResultsToReport(_PingReportResponse_t *pResults,SlPingReport_t *pReport);
dflet 6:778b081f6a13 534
dflet 6:778b081f6a13 535 #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
dflet 6:778b081f6a13 536 uint16_t sl_NetAppSendTokenValue(slHttpServerData_t * Token);
dflet 6:778b081f6a13 537 #endif
dflet 6:778b081f6a13 538
dflet 6:778b081f6a13 539 // uint16_t sl_NetAppSendTokenValue(slHttpServerData_t * Token);
dflet 6:778b081f6a13 540
dflet 6:778b081f6a13 541
dflet 6:778b081f6a13 542 /*****************************************************************************/
dflet 6:778b081f6a13 543 /* Function prototypes */
dflet 6:778b081f6a13 544 /*****************************************************************************/
dflet 6:778b081f6a13 545
dflet 6:778b081f6a13 546
dflet 6:778b081f6a13 547 /*!
dflet 6:778b081f6a13 548 \brief Starts a network application
dflet 6:778b081f6a13 549
dflet 6:778b081f6a13 550 Gets and starts network application for the current WLAN mode
dflet 6:778b081f6a13 551
dflet 6:778b081f6a13 552 \param[in] AppBitMap application bitmap, could be one or combination of the following: \n
dflet 6:778b081f6a13 553 - SL_NET_APP_HTTP_SERVER_ID
dflet 6:778b081f6a13 554 - SL_NET_APP_DHCP_SERVER_ID
dflet 6:778b081f6a13 555 - SL_NET_APP_MDNS_ID
dflet 6:778b081f6a13 556
dflet 6:778b081f6a13 557 \return On error, negative number is returned
dflet 6:778b081f6a13 558
dflet 6:778b081f6a13 559 \sa Stop one or more the above started applications using sl_NetAppStop
dflet 6:778b081f6a13 560 \note This command activates the application for the current WLAN mode (AP or STA)
dflet 6:778b081f6a13 561 \warning
dflet 6:778b081f6a13 562 \par Example:
dflet 6:778b081f6a13 563 \code
dflet 6:778b081f6a13 564 For example: Starting internal HTTP server + DHCP server:
dflet 6:778b081f6a13 565 sl_NetAppStart(SL_NET_APP_HTTP_SERVER_ID | SL_NET_APP_DHCP_SERVER_ID)
dflet 6:778b081f6a13 566
dflet 6:778b081f6a13 567 \endcode
dflet 6:778b081f6a13 568 */
dflet 6:778b081f6a13 569 #if _SL_INCLUDE_FUNC(sl_NetAppStart)
dflet 6:778b081f6a13 570 int16_t sl_NetAppStart(const uint32_t AppBitMap);
dflet 6:778b081f6a13 571 #endif
dflet 6:778b081f6a13 572 /*!
dflet 6:778b081f6a13 573 \brief Stops a network application
dflet 6:778b081f6a13 574
dflet 6:778b081f6a13 575 Gets and stops network application for the current WLAN mode
dflet 6:778b081f6a13 576
dflet 6:778b081f6a13 577 \param[in] AppBitMap application id, could be one of the following: \n
dflet 6:778b081f6a13 578 - SL_NET_APP_HTTP_SERVER_ID
dflet 6:778b081f6a13 579 - SL_NET_APP_DHCP_SERVER_ID
dflet 6:778b081f6a13 580 - SL_NET_APP_MDNS_ID
dflet 6:778b081f6a13 581
dflet 6:778b081f6a13 582 \return On error, negative number is returned
dflet 6:778b081f6a13 583
dflet 6:778b081f6a13 584 \sa
dflet 6:778b081f6a13 585 \note This command disables the application for the current active WLAN mode (AP or STA)
dflet 6:778b081f6a13 586 \warning
dflet 6:778b081f6a13 587 \par Example:
dflet 6:778b081f6a13 588 \code
dflet 6:778b081f6a13 589
dflet 6:778b081f6a13 590 For example: Stopping internal HTTP server:
dflet 6:778b081f6a13 591 sl_NetAppStop(SL_NET_APP_HTTP_SERVER_ID);
dflet 6:778b081f6a13 592
dflet 6:778b081f6a13 593 \endcode
dflet 6:778b081f6a13 594 */
dflet 6:778b081f6a13 595 #if _SL_INCLUDE_FUNC(sl_NetAppStop)
dflet 6:778b081f6a13 596 int16_t sl_NetAppStop(const uint32_t AppBitMap);
dflet 6:778b081f6a13 597 #endif
dflet 6:778b081f6a13 598
dflet 6:778b081f6a13 599 /*!
dflet 6:778b081f6a13 600 \brief Get host IP by name
dflet 6:778b081f6a13 601
dflet 6:778b081f6a13 602 Obtain the IP Address of machine on network, by machine name.
dflet 6:778b081f6a13 603
dflet 6:778b081f6a13 604 \param[in] hostname host name
dflet 6:778b081f6a13 605 \param[in] usNameLen name length
dflet 6:778b081f6a13 606 \param[out] out_ip_addr This parameter is filled in with
dflet 6:778b081f6a13 607 host IP address. In case that host name is not
dflet 6:778b081f6a13 608 resolved, out_ip_addr is zero.
dflet 6:778b081f6a13 609 \param[in] family protocol family
dflet 6:778b081f6a13 610
dflet 6:778b081f6a13 611 \return On success, 0 is returned.
dflet 6:778b081f6a13 612 On error, negative is returned
dflet 6:778b081f6a13 613 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
dflet 6:778b081f6a13 614 In this case try again later or increase MAX_CONCURRENT_ACTIONS
dflet 6:778b081f6a13 615 Possible DNS error codes:
dflet 6:778b081f6a13 616 - SL_NET_APP_DNS_QUERY_NO_RESPONSE
dflet 6:778b081f6a13 617 - SL_NET_APP_DNS_NO_SERVER
dflet 6:778b081f6a13 618 - SL_NET_APP_DNS_QUERY_FAILED
dflet 6:778b081f6a13 619 - SL_NET_APP_DNS_MALFORMED_PACKET
dflet 6:778b081f6a13 620 - SL_NET_APP_DNS_MISMATCHED_RESPONSE
dflet 6:778b081f6a13 621
dflet 6:778b081f6a13 622 \sa
dflet 6:778b081f6a13 623 \note Only one sl_NetAppDnsGetHostByName can be handled at a time.
dflet 6:778b081f6a13 624 Calling this API while the same command is called from another thread, may result
dflet 6:778b081f6a13 625 in one of the two scenarios:
dflet 6:778b081f6a13 626 1. The command will wait (internal) until the previous command finish, and then be executed.
dflet 6:778b081f6a13 627 2. There are not enough resources and POOL_IS_EMPTY error will return.
dflet 6:778b081f6a13 628 In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
dflet 6:778b081f6a13 629 again later to issue the command.
dflet 6:778b081f6a13 630 \warning
dflet 6:778b081f6a13 631 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
dflet 6:778b081f6a13 632 try to access the DNS and it will return the input address on the 'out_ip_addr' field
dflet 6:778b081f6a13 633 \par Example:
dflet 6:778b081f6a13 634 \code
dflet 6:778b081f6a13 635 uint32_t DestinationIP;
dflet 6:778b081f6a13 636 sl_NetAppDnsGetHostByName("www.google.com", strlen("www.google.com"), &DestinationIP,SL_AF_INET);
dflet 6:778b081f6a13 637
dflet 6:778b081f6a13 638 Addr.sin_family = SL_AF_INET;
dflet 6:778b081f6a13 639 Addr.sin_port = sl_Htons(80);
dflet 6:778b081f6a13 640 Addr.sin_addr.s_addr = sl_Htonl(DestinationIP);
dflet 6:778b081f6a13 641 AddrSize = sizeof(SlSockAddrIn_t);
dflet 6:778b081f6a13 642 SockID = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0);
dflet 6:778b081f6a13 643 \endcode
dflet 6:778b081f6a13 644 */
dflet 6:778b081f6a13 645 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByName)
dflet 6:778b081f6a13 646 int16_t sl_NetAppDnsGetHostByName(unsigned char * hostname, const uint16_t usNameLen, uint32_t* out_ip_addr, const uint8_t family );
dflet 6:778b081f6a13 647 #endif
dflet 6:778b081f6a13 648
dflet 6:778b081f6a13 649 /*!
dflet 6:778b081f6a13 650 \brief Return service attributes like IP address, port and text according to service name
dflet 6:778b081f6a13 651 \par
dflet 6:778b081f6a13 652 The user sets a service name Full/Part (see example below), and should get:
dflet 6:778b081f6a13 653 - IP of service
dflet 6:778b081f6a13 654 - The port of service
dflet 6:778b081f6a13 655 - The text of service
dflet 6:778b081f6a13 656
dflet 6:778b081f6a13 657 Hence it can make a connection to the specific service and use it.
dflet 6:778b081f6a13 658 It is similar to get host by name method.
dflet 6:778b081f6a13 659 It is done by a single shot query with PTR type on the service name.
dflet 6:778b081f6a13 660 The command that is sent is from constant parameters and variables parameters.
dflet 6:778b081f6a13 661
dflet 6:778b081f6a13 662 \param[in] pService Service name can be full or partial. \n
dflet 6:778b081f6a13 663 Example for full service name:
dflet 6:778b081f6a13 664 1. PC1._ipp._tcp.local
dflet 6:778b081f6a13 665 2. PC2_server._ftp._tcp.local \n
dflet 6:778b081f6a13 666 .
dflet 6:778b081f6a13 667 Example for partial service name:
dflet 6:778b081f6a13 668 1. _ipp._tcp.local
dflet 6:778b081f6a13 669 2. _ftp._tcp.local
dflet 6:778b081f6a13 670
dflet 6:778b081f6a13 671 \param[in] ServiceLen The length of the service name (in_pService).
dflet 6:778b081f6a13 672 \param[in] Family IPv4 or IPv6 (SL_AF_INET , SL_AF_INET6).
dflet 6:778b081f6a13 673 \param[out] pAddr Contains the IP address of the service.
dflet 6:778b081f6a13 674 \param[out] pPort Contains the port of the service.
dflet 6:778b081f6a13 675 \param[out] pTextLen Has 2 options. One as Input field and the other one as output:
dflet 6:778b081f6a13 676 - Input: \n
dflet 6:778b081f6a13 677 Contains the max length of the text that the user wants to get.\n
dflet 6:778b081f6a13 678 It means that if the text len of service is bigger that its value than
dflet 6:778b081f6a13 679 the text is cut to inout_TextLen value.
dflet 6:778b081f6a13 680 - Output: \n
dflet 6:778b081f6a13 681 Contain the length of the text that is returned. Can be full text or part of the text (see above).
dflet 6:778b081f6a13 682
dflet 6:778b081f6a13 683 \param[out] pOut_pText Contains the text of the service full or partial
dflet 6:778b081f6a13 684
dflet 6:778b081f6a13 685 \return On success, zero is returned
dflet 6:778b081f6a13 686 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
dflet 6:778b081f6a13 687 In this case try again later or increase MAX_CONCURRENT_ACTIONS
dflet 6:778b081f6a13 688 In case No service is found error SL_NET_APP_DNS_NO_ANSWER will be returned
dflet 6:778b081f6a13 689
dflet 6:778b081f6a13 690 \note The returns attributes belongs to the first service found.
dflet 6:778b081f6a13 691 There may be other services with the same service name that will response to the query.
dflet 6:778b081f6a13 692 The results of these responses are saved in the peer cache of the Device and should be read by another API.
dflet 6:778b081f6a13 693
dflet 6:778b081f6a13 694 Only one sl_NetAppDnsGetHostByService can be handled at a time.
dflet 6:778b081f6a13 695 Calling this API while the same command is called from another thread, may result
dflet 6:778b081f6a13 696 in one of the two scenarios:
dflet 6:778b081f6a13 697 1. The command will wait (internal) until the previous command finish, and then be executed.
dflet 6:778b081f6a13 698 2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
dflet 6:778b081f6a13 699 In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
dflet 6:778b081f6a13 700 again later to issue the command.
dflet 6:778b081f6a13 701
dflet 6:778b081f6a13 702 \warning Text length can be 120 bytes only
dflet 6:778b081f6a13 703 */
dflet 6:778b081f6a13 704 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByService)
dflet 6:778b081f6a13 705 int32_t sl_NetAppDnsGetHostByService(unsigned char *pServiceName, /* string containing all (or only part): name + subtype + service */
dflet 6:778b081f6a13 706 const uint8_t ServiceLen,
dflet 6:778b081f6a13 707 const uint8_t Family, /* 4-IPv4 , 16-IPv6 */
dflet 6:778b081f6a13 708 uint32_t pAddr[],
dflet 6:778b081f6a13 709 uint32_t *pPort,
dflet 6:778b081f6a13 710 uint16_t *pTextLen, /* in: max len , out: actual len */
dflet 6:778b081f6a13 711 unsigned char *pText
dflet 6:778b081f6a13 712 );
dflet 6:778b081f6a13 713
dflet 6:778b081f6a13 714 #endif
dflet 6:778b081f6a13 715
dflet 6:778b081f6a13 716 /*!
dflet 6:778b081f6a13 717 \brief Get service List
dflet 6:778b081f6a13 718 Insert into out pBuffer a list of peer's services that are the NWP.
dflet 6:778b081f6a13 719 The list is in a form of service struct. The user should chose the type
dflet 6:778b081f6a13 720 of the service struct like:
dflet 6:778b081f6a13 721 - Full service parameters with text.
dflet 6:778b081f6a13 722 - Full service parameters.
dflet 6:778b081f6a13 723 - Short service parameters (port and IP only) especially for tiny hosts.
dflet 6:778b081f6a13 724
dflet 6:778b081f6a13 725 The different types of struct are made to give the
dflet 6:778b081f6a13 726 Possibility to save memory in the host
dflet 6:778b081f6a13 727
dflet 6:778b081f6a13 728
dflet 6:778b081f6a13 729 The user also chose how many max services to get and start point index
dflet 6:778b081f6a13 730 NWP peer cache.
dflet 6:778b081f6a13 731 For example:
dflet 6:778b081f6a13 732 1. Get max of 3 full services from index 0.Up to 3 full services
dflet 6:778b081f6a13 733 from index 0 are inserted into pBuffer (services that are in indexes 0,1,2).
dflet 6:778b081f6a13 734 2. Get max of 4 full services from index 3.Up to 4 full services
dflet 6:778b081f6a13 735 from index 3 are inserted into pBuffer (services that are in indexes 3,4,5,6).
dflet 6:778b081f6a13 736 3. Get max of 2 int services from index 6.Up to 2 int services
dflet 6:778b081f6a13 737 from index 6 are inserted into pBuffer (services that are in indexes 6,7).
dflet 6:778b081f6a13 738
dflet 6:778b081f6a13 739 See below - command parameters.
dflet 6:778b081f6a13 740
dflet 6:778b081f6a13 741 \param[in] indexOffset - The start index in the peer cache that from it the first service is returned.
dflet 6:778b081f6a13 742 \param[in] MaxServiceCount - The Max services that can be returned if existed or if not exceed the max index
dflet 6:778b081f6a13 743 in the peer cache
dflet 6:778b081f6a13 744 \param[in] Flags - an ENUM number that means which service struct to use (means which types of service to fill)
dflet 6:778b081f6a13 745 - use SlNetAppGetFullServiceWithTextIpv4List_t
dflet 6:778b081f6a13 746 - use SlNetAppGetFullServiceIpv4List_t
dflet 6:778b081f6a13 747 - use SlNetAppGetShortServiceIpv4List_t
dflet 6:778b081f6a13 748
dflet 6:778b081f6a13 749 \param[out] Buffer - The Services are inserted into this buffer. In the struct form according to the bit that is set in the Flags
dflet 6:778b081f6a13 750 input parameter.
dflet 6:778b081f6a13 751
dflet 6:778b081f6a13 752 \return ServiceFoundCount - The number of the services that were inserted into the buffer. zero means no service is found
dflet 6:778b081f6a13 753 negative number means an error
dflet 6:778b081f6a13 754 \sa sl_NetAppMDNSRegisterService
dflet 6:778b081f6a13 755 \note
dflet 6:778b081f6a13 756 \warning
dflet 6:778b081f6a13 757 if the out pBuffer size is bigger than an RX packet(1480), than
dflet 6:778b081f6a13 758 an error is returned because there
dflet 6:778b081f6a13 759 is no place in the RX packet.
dflet 6:778b081f6a13 760 The size is a multiply of MaxServiceCount and size of service struct(that is set
dflet 6:778b081f6a13 761 according to flag value).
dflet 6:778b081f6a13 762 */
dflet 6:778b081f6a13 763
dflet 6:778b081f6a13 764 #if _SL_INCLUDE_FUNC(sl_NetAppGetServiceList)
dflet 6:778b081f6a13 765 int16_t sl_NetAppGetServiceList(const uint8_t IndexOffest,
dflet 6:778b081f6a13 766 const uint8_t MaxServiceCount,
dflet 6:778b081f6a13 767 const uint8_t Flags,
dflet 6:778b081f6a13 768 int8_t *pBuffer,
dflet 6:778b081f6a13 769 const uint32_t RxBufferLength
dflet 6:778b081f6a13 770 );
dflet 6:778b081f6a13 771
dflet 6:778b081f6a13 772 #endif
dflet 6:778b081f6a13 773
dflet 6:778b081f6a13 774 /*!
dflet 6:778b081f6a13 775 \brief Unregister mDNS service
dflet 6:778b081f6a13 776 This function deletes the mDNS service from the mDNS package and the database.
dflet 6:778b081f6a13 777
dflet 6:778b081f6a13 778 The mDNS service that is to be unregistered is a service that the application no longer wishes to provide. \n
dflet 6:778b081f6a13 779 The service name should be the full service name according to RFC
dflet 6:778b081f6a13 780 of the DNS-SD - meaning the value in name field in the SRV answer.
dflet 6:778b081f6a13 781
dflet 6:778b081f6a13 782 Examples for service names:
dflet 6:778b081f6a13 783 1. PC1._ipp._tcp.local
dflet 6:778b081f6a13 784 2. PC2_server._ftp._tcp.local
dflet 6:778b081f6a13 785
dflet 6:778b081f6a13 786 \param[in] pServiceName Full service name. \n
dflet 6:778b081f6a13 787 Example for service name:
dflet 6:778b081f6a13 788 1. PC1._ipp._tcp.local
dflet 6:778b081f6a13 789 2. PC2_server._ftp._tcp.local
dflet 6:778b081f6a13 790 \param[in] ServiceLen The length of the service.
dflet 6:778b081f6a13 791 \return On success, zero is returned
dflet 6:778b081f6a13 792 \sa sl_NetAppMDNSRegisterService
dflet 6:778b081f6a13 793 \note
dflet 6:778b081f6a13 794 \warning
dflet 6:778b081f6a13 795 The size of the service length should be smaller than 255.
dflet 6:778b081f6a13 796 */
dflet 6:778b081f6a13 797 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService)
dflet 6:778b081f6a13 798 int16_t sl_NetAppMDNSUnRegisterService(const char *pServiceName, const uint8_t ServiceNameLen);
dflet 6:778b081f6a13 799 #endif
dflet 6:778b081f6a13 800
dflet 6:778b081f6a13 801 /*!
dflet 6:778b081f6a13 802 \brief Register a new mDNS service
dflet 6:778b081f6a13 803 \par
dflet 6:778b081f6a13 804 This function registers a new mDNS service to the mDNS package and the DB.
dflet 6:778b081f6a13 805
dflet 6:778b081f6a13 806 This registered service is a service offered by the application.
dflet 6:778b081f6a13 807 The service name should be full service name according to RFC
dflet 6:778b081f6a13 808 of the DNS-SD - meaning the value in name field in the SRV answer.
dflet 6:778b081f6a13 809 Example for service name:
dflet 6:778b081f6a13 810 1. PC1._ipp._tcp.local
dflet 6:778b081f6a13 811 2. PC2_server._ftp._tcp.local
dflet 6:778b081f6a13 812
dflet 6:778b081f6a13 813 If the option is_unique is set, mDNS probes the service name to make sure
dflet 6:778b081f6a13 814 it is unique before starting to announce the service on the network.
dflet 6:778b081f6a13 815 Instance is the instance portion of the service name.
dflet 6:778b081f6a13 816
dflet 6:778b081f6a13 817 \param[in] ServiceLen The length of the service.
dflet 6:778b081f6a13 818 \param[in] TextLen The length of the service should be smaller than 64.
dflet 6:778b081f6a13 819 \param[in] port The port on this target host port.
dflet 6:778b081f6a13 820 \param[in] TTL The TTL of the service
dflet 6:778b081f6a13 821 \param[in] Options bitwise parameters: \n
dflet 6:778b081f6a13 822 - bit 0 - service is unique (means that the service needs to be unique)
dflet 6:778b081f6a13 823 - bit 31 - for internal use if the service should be added or deleted (set means ADD).
dflet 6:778b081f6a13 824 - bit 1-30 for future.
dflet 6:778b081f6a13 825
dflet 6:778b081f6a13 826 \param[in] pServiceName The service name.
dflet 6:778b081f6a13 827 Example for service name: \n
dflet 6:778b081f6a13 828 1. PC1._ipp._tcp.local
dflet 6:778b081f6a13 829 2. PC2_server._ftp._tcp.local
dflet 6:778b081f6a13 830
dflet 6:778b081f6a13 831 \param[in] pText The description of the service.
dflet 6:778b081f6a13 832 should be as mentioned in the RFC
dflet 6:778b081f6a13 833 (according to type of the service IPP,FTP...)
dflet 6:778b081f6a13 834
dflet 6:778b081f6a13 835 \return On success, zero is returned
dflet 6:778b081f6a13 836 Possible error codes:
dflet 6:778b081f6a13 837 - Maximum advertise services are already configured.
dflet 6:778b081f6a13 838 Delete another existed service that is registered and then register again the new service
dflet 6:778b081f6a13 839 - Trying to register a service that is already exists
dflet 6:778b081f6a13 840 - Trying to delete service that does not existed
dflet 6:778b081f6a13 841 - Illegal service name according to the RFC
dflet 6:778b081f6a13 842 - Retry request
dflet 6:778b081f6a13 843 - Illegal length of one of the mDNS Set functions
dflet 6:778b081f6a13 844 - mDNS is not operational as the device has no IP.Connect the device to an AP to get an IP address.
dflet 6:778b081f6a13 845 - mDNS parameters error
dflet 6:778b081f6a13 846 - mDNS internal cache error
dflet 6:778b081f6a13 847 - mDNS internal error
dflet 6:778b081f6a13 848 - Adding a service is not allowed as it is already exist (duplicate service)
dflet 6:778b081f6a13 849 - mDNS is not running
dflet 6:778b081f6a13 850 - Host name error. Host name format is not allowed according to RFC 1033,1034,1035, 6763
dflet 6:778b081f6a13 851 - List size buffer is bigger than internally allowed in the NWP (API get service list),
dflet 6:778b081f6a13 852 change the APIs� parameters to decrease the size of the list
dflet 6:778b081f6a13 853
dflet 6:778b081f6a13 854
dflet 6:778b081f6a13 855 \sa sl_NetAppMDNSUnRegisterService
dflet 6:778b081f6a13 856
dflet 6:778b081f6a13 857 \warning 1) Temporary - there is an allocation on stack of internal buffer.
dflet 6:778b081f6a13 858 Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. \n
dflet 6:778b081f6a13 859 It means that the sum of the text length and service name length cannot be bigger than
dflet 6:778b081f6a13 860 NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.\n
dflet 6:778b081f6a13 861 If it is - An error is returned. \n
dflet 6:778b081f6a13 862 2) According to now from certain constraints the variables parameters are set in the
dflet 6:778b081f6a13 863 attribute part (contain constant parameters)
dflet 6:778b081f6a13 864 */
dflet 6:778b081f6a13 865 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService)
dflet 6:778b081f6a13 866 int16_t sl_NetAppMDNSRegisterService( const char* pServiceName,
dflet 6:778b081f6a13 867 const uint8_t ServiceNameLen,
dflet 6:778b081f6a13 868 const char* pText,
dflet 6:778b081f6a13 869 const uint8_t TextLen,
dflet 6:778b081f6a13 870 const uint16_t Port,
dflet 6:778b081f6a13 871 const uint32_t TTL,
dflet 6:778b081f6a13 872 uint32_t Options);
dflet 6:778b081f6a13 873 #endif
dflet 6:778b081f6a13 874
dflet 6:778b081f6a13 875 /*!
dflet 6:778b081f6a13 876 \brief send ICMP ECHO_REQUEST to network hosts
dflet 6:778b081f6a13 877
dflet 6:778b081f6a13 878 Ping uses the ICMP protocol's mandatory ECHO_REQUEST
dflet 6:778b081f6a13 879
dflet 6:778b081f6a13 880 \param[in] pPingParams Pointer to the ping request structure: \n
dflet 6:778b081f6a13 881 - if flags parameter is set to 0, ping will report back once all requested pings are done (as defined by TotalNumberOfAttempts). \n
dflet 6:778b081f6a13 882 - if flags parameter is set to 1, ping will report back after every ping, for TotalNumberOfAttempts.
dflet 6:778b081f6a13 883 - 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.
dflet 6:778b081f6a13 884 For stopping an ongoing ping activity, set parameters IP address to 0
dflet 6:778b081f6a13 885
dflet 6:778b081f6a13 886 \param[in] family SL_AF_INET or SL_AF_INET6
dflet 6:778b081f6a13 887 \param[out] pReport Ping pReport
dflet 6:778b081f6a13 888 \param[out] pCallback Callback function upon completion.
dflet 6:778b081f6a13 889 If callback is NULL, the API is blocked until data arrives
dflet 6:778b081f6a13 890
dflet 6:778b081f6a13 891
dflet 6:778b081f6a13 892 \return On success, zero is returned. On error, -1 is returned
dflet 6:778b081f6a13 893 SL_POOL_IS_EMPTY may be return in case there are no resources in the system
dflet 6:778b081f6a13 894 In this case try again later or increase MAX_CONCURRENT_ACTIONS
dflet 6:778b081f6a13 895
dflet 6:778b081f6a13 896 \sa sl_NetAppPingReport
dflet 6:778b081f6a13 897 \note Only one sl_NetAppPingStart can be handled at a time.
dflet 6:778b081f6a13 898 Calling this API while the same command is called from another thread, may result
dflet 6:778b081f6a13 899 in one of the two scenarios:
dflet 6:778b081f6a13 900 1. The command will wait (internal) until the previous command finish, and then be executed.
dflet 6:778b081f6a13 901 2. There are not enough resources and SL_POOL_IS_EMPTY error will return.
dflet 6:778b081f6a13 902 In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try
dflet 6:778b081f6a13 903 again later to issue the command.
dflet 6:778b081f6a13 904 \warning
dflet 6:778b081f6a13 905 \par Example:
dflet 6:778b081f6a13 906 \code
dflet 6:778b081f6a13 907
dflet 6:778b081f6a13 908 An example of sending 20 ping requests and reporting results to a callback routine when
dflet 6:778b081f6a13 909 all requests are sent:
dflet 6:778b081f6a13 910
dflet 6:778b081f6a13 911 // callback routine
dflet 6:778b081f6a13 912 void pingRes(SlPingReport_t* pReport)
dflet 6:778b081f6a13 913 {
dflet 6:778b081f6a13 914 // handle ping results
dflet 6:778b081f6a13 915 }
dflet 6:778b081f6a13 916
dflet 6:778b081f6a13 917 // ping activation
dflet 6:778b081f6a13 918 void PingTest()
dflet 6:778b081f6a13 919 {
dflet 6:778b081f6a13 920 SlPingReport_t report;
dflet 6:778b081f6a13 921 SlPingStartCommand_t pingCommand;
dflet 6:778b081f6a13 922
dflet 6:778b081f6a13 923 pingCommand.Ip = SL_IPV4_VAL(10,1,1,200); // destination IP address is 10.1.1.200
dflet 6:778b081f6a13 924 pingCommand.PingSize = 150; // size of ping, in bytes
dflet 6:778b081f6a13 925 pingCommand.PingIntervalTime = 100; // delay between pings, in milliseconds
dflet 6:778b081f6a13 926 pingCommand.PingRequestTimeout = 1000; // timeout for every ping in milliseconds
dflet 6:778b081f6a13 927 pingCommand.TotalNumberOfAttempts = 20; // max number of ping requests. 0 - forever
dflet 6:778b081f6a13 928 pingCommand.Flags = 0; // report only when finished
dflet 6:778b081f6a13 929
dflet 6:778b081f6a13 930 sl_NetAppPingStart( &pingCommand, SL_AF_INET, &report, pingRes ) ;
dflet 6:778b081f6a13 931 }
dflet 6:778b081f6a13 932
dflet 6:778b081f6a13 933 \endcode
dflet 6:778b081f6a13 934 */
dflet 6:778b081f6a13 935 #if _SL_INCLUDE_FUNC(sl_NetAppPingStart)
dflet 6:778b081f6a13 936 int16_t sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams, const uint8_t family,SlPingReport_t *pReport, const P_SL_DEV_PING_CALLBACK pPingCallback);
dflet 6:778b081f6a13 937 #endif
dflet 6:778b081f6a13 938
dflet 6:778b081f6a13 939 /*!
dflet 6:778b081f6a13 940 \brief Internal function for setting network application configurations
dflet 6:778b081f6a13 941
dflet 6:778b081f6a13 942 \return On success, zero is returned. On error, -1 is
dflet 6:778b081f6a13 943 returned
dflet 6:778b081f6a13 944
dflet 6:778b081f6a13 945 \param[in] AppId Application id, could be one of the following: \n
dflet 6:778b081f6a13 946 - SL_NET_APP_HTTP_SERVER_ID
dflet 6:778b081f6a13 947 - SL_NET_APP_DHCP_SERVER_ID
dflet 6:778b081f6a13 948 - SL_NET_APP_MDNS_ID
dflet 6:778b081f6a13 949 - SL_NET_APP_DEVICE_CONFIG_ID
dflet 6:778b081f6a13 950
dflet 6:778b081f6a13 951 \param[in] SetOptions set option, could be one of the following: \n
dflet 6:778b081f6a13 952 - SL_NET_APP_DHCP_SERVER_ID
dflet 6:778b081f6a13 953 - NETAPP_SET_DHCP_SRV_BASIC_OPT
dflet 6:778b081f6a13 954 - SL_NET_APP_HTTP_SERVER_ID
dflet 6:778b081f6a13 955 - NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
dflet 6:778b081f6a13 956 - NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
dflet 6:778b081f6a13 957 - NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
dflet 6:778b081f6a13 958 - NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
dflet 6:778b081f6a13 959 - NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
dflet 6:778b081f6a13 960 - NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
dflet 6:778b081f6a13 961 - SL_NET_APP_MDNS_ID
dflet 6:778b081f6a13 962 - NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
dflet 6:778b081f6a13 963 - NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
dflet 6:778b081f6a13 964 - NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
dflet 6:778b081f6a13 965 - SL_NET_APP_DEVICE_CONFIG_ID
dflet 6:778b081f6a13 966 - NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
dflet 6:778b081f6a13 967 - NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
dflet 6:778b081f6a13 968
dflet 6:778b081f6a13 969
dflet 6:778b081f6a13 970 \param[in] OptionLen option structure length
dflet 6:778b081f6a13 971
dflet 6:778b081f6a13 972 \param[in] pOptionValues pointer to the option structure
dflet 6:778b081f6a13 973 \sa
dflet 6:778b081f6a13 974 \note
dflet 6:778b081f6a13 975 \warning
dflet 6:778b081f6a13 976 \par
dflet 6:778b081f6a13 977 \code
dflet 6:778b081f6a13 978 Set DHCP Server (AP mode) parameters example:
dflet 6:778b081f6a13 979
dflet 6:778b081f6a13 980 SlNetAppDhcpServerBasicOpt_t dhcpParams;
dflet 6:778b081f6a13 981 uint8_t outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
dflet 6:778b081f6a13 982 dhcpParams.lease_time = 4096; // lease time (in seconds) of the IP Address
dflet 6:778b081f6a13 983 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)
dflet 6:778b081f6a13 984 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)
dflet 6:778b081f6a13 985 sl_NetAppStop(SL_NET_APP_DHCP_SERVER_ID); // Stop DHCP server before settings
dflet 6:778b081f6a13 986 sl_NetAppSet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, outLen, (uint8_t* )&dhcpParams); // set parameters
dflet 6:778b081f6a13 987 sl_NetAppStart(SL_NET_APP_DHCP_SERVER_ID); // Start DHCP server with new settings
dflet 6:778b081f6a13 988 \endcode
dflet 6:778b081f6a13 989 \code
dflet 6:778b081f6a13 990 Set Device URN name example:
dflet 6:778b081f6a13 991
dflet 6:778b081f6a13 992 Device name, maximum length of 33 characters
dflet 6:778b081f6a13 993 Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
dflet 6:778b081f6a13 994 In case no device URN name set, the default name is "mysimplelink"
dflet 6:778b081f6a13 995 Allowed characters in device name are: 'a - z' , 'A - Z' , '0-9' and '-'
dflet 6:778b081f6a13 996
dflet 6:778b081f6a13 997 uint8_t *my_device = "MY-SIMPLELINK-DEV";
dflet 6:778b081f6a13 998 sl_NetAppSet (SL_NET_APP_DEVICE_CONFIG_ID, NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN, strlen(my_device), (uint8_t *) my_device);
dflet 6:778b081f6a13 999 \endcode
dflet 6:778b081f6a13 1000
dflet 6:778b081f6a13 1001 */
dflet 6:778b081f6a13 1002 #if _SL_INCLUDE_FUNC(sl_NetAppSet)
dflet 6:778b081f6a13 1003 int32_t sl_NetAppSet(const uint8_t AppId, const uint8_t Option, const uint8_t OptionLen, const uint8_t *pOptionValue);
dflet 6:778b081f6a13 1004 #endif
dflet 6:778b081f6a13 1005
dflet 6:778b081f6a13 1006 /*!
dflet 6:778b081f6a13 1007 \brief Internal function for getting network applications configurations
dflet 6:778b081f6a13 1008
dflet 6:778b081f6a13 1009 \return On success, zero is returned. On error, -1 is
dflet 6:778b081f6a13 1010 returned
dflet 6:778b081f6a13 1011
dflet 6:778b081f6a13 1012 \param[in] AppId Application id, could be one of the following: \n
dflet 6:778b081f6a13 1013 - SL_NET_APP_HTTP_SERVER_ID
dflet 6:778b081f6a13 1014 - SL_NET_APP_DHCP_SERVER_ID
dflet 6:778b081f6a13 1015 - SL_NET_APP_MDNS_ID
dflet 6:778b081f6a13 1016 - SL_NET_APP_DEVICE_CONFIG_ID
dflet 6:778b081f6a13 1017
dflet 6:778b081f6a13 1018 \param[in] SetOptions set option, could be one of the following: \n
dflet 6:778b081f6a13 1019 - SL_NET_APP_DHCP_SERVER_ID
dflet 6:778b081f6a13 1020 - NETAPP_SET_DHCP_SRV_BASIC_OPT
dflet 6:778b081f6a13 1021 - SL_NET_APP_HTTP_SERVER_ID
dflet 6:778b081f6a13 1022 - NETAPP_SET_GET_HTTP_OPT_PORT_NUMBER
dflet 6:778b081f6a13 1023 - NETAPP_SET_GET_HTTP_OPT_AUTH_CHECK
dflet 6:778b081f6a13 1024 - NETAPP_SET_GET_HTTP_OPT_AUTH_NAME
dflet 6:778b081f6a13 1025 - NETAPP_SET_GET_HTTP_OPT_AUTH_PASSWORD
dflet 6:778b081f6a13 1026 - NETAPP_SET_GET_HTTP_OPT_AUTH_REALM
dflet 6:778b081f6a13 1027 - NETAPP_SET_GET_HTTP_OPT_ROM_PAGES_ACCESS
dflet 6:778b081f6a13 1028 - SL_NET_APP_MDNS_ID
dflet 6:778b081f6a13 1029 - NETAPP_SET_GET_MDNS_CONT_QUERY_OPT
dflet 6:778b081f6a13 1030 - NETAPP_SET_GET_MDNS_QEVETN_MASK_OPT
dflet 6:778b081f6a13 1031 - NETAPP_SET_GET_MDNS_TIMING_PARAMS_OPT
dflet 6:778b081f6a13 1032 - SL_NET_APP_DEVICE_CONFIG_ID
dflet 6:778b081f6a13 1033 - NETAPP_SET_GET_DEV_CONF_OPT_DEVICE_URN
dflet 6:778b081f6a13 1034 - NETAPP_SET_GET_DEV_CONF_OPT_DOMAIN_NAME
dflet 6:778b081f6a13 1035
dflet 6:778b081f6a13 1036 \param[in] OptionLen The length of the allocated memory as input, when the
dflet 6:778b081f6a13 1037 function complete, the value of this parameter would be
dflet 6:778b081f6a13 1038 the len that actually read from the device.
dflet 6:778b081f6a13 1039 If the device return length that is longer from the input
dflet 6:778b081f6a13 1040 value, the function will cut the end of the returned structure
dflet 6:778b081f6a13 1041 and will return ESMALLBUF
dflet 6:778b081f6a13 1042
dflet 6:778b081f6a13 1043 \param[out] pValues pointer to the option structure which will be filled with the response from the device
dflet 6:778b081f6a13 1044
dflet 6:778b081f6a13 1045 \sa
dflet 6:778b081f6a13 1046 \note
dflet 6:778b081f6a13 1047 \warning
dflet 6:778b081f6a13 1048 \par
dflet 6:778b081f6a13 1049 \code
dflet 6:778b081f6a13 1050 Get DHCP Server parameters example:
dflet 6:778b081f6a13 1051
dflet 6:778b081f6a13 1052 SlNetAppDhcpServerBasicOpt_t dhcpParams;
dflet 6:778b081f6a13 1053 uint8_t outLen = sizeof(SlNetAppDhcpServerBasicOpt_t);
dflet 6:778b081f6a13 1054 sl_NetAppGet(SL_NET_APP_DHCP_SERVER_ID, NETAPP_SET_DHCP_SRV_BASIC_OPT, &outLen, (uint8_t* )&dhcpParams);
dflet 6:778b081f6a13 1055
dflet 6:778b081f6a13 1056 printf("DHCP Start IP %d.%d.%d.%d End IP %d.%d.%d.%d Lease time seconds %d\n",
dflet 6:778b081f6a13 1057 SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,2),
dflet 6:778b081f6a13 1058 SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,0),
dflet 6:778b081f6a13 1059 SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,2),
dflet 6:778b081f6a13 1060 SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,0),
dflet 6:778b081f6a13 1061 dhcpParams.lease_time);
dflet 6:778b081f6a13 1062 \endcode
dflet 6:778b081f6a13 1063 \code
dflet 6:778b081f6a13 1064 Get Device URN name example:
dflet 6:778b081f6a13 1065 Maximum length of 33 characters of device name.
dflet 6:778b081f6a13 1066 Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P)
dflet 6:778b081f6a13 1067 in case no device URN name set, the default name is "mysimplelink"
dflet 6:778b081f6a13 1068
dflet 6:778b081f6a13 1069 uint8_t my_device_name[35];
dflet 6:778b081f6a13 1070 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);
dflet 6:778b081f6a13 1071 \endcode
dflet 6:778b081f6a13 1072 */
dflet 6:778b081f6a13 1073 #if _SL_INCLUDE_FUNC(sl_NetAppGet)
dflet 6:778b081f6a13 1074 int32_t sl_NetAppGet(const uint8_t AppId, const uint8_t Option,uint8_t *pOptionLen, uint8_t *pOptionValue);
dflet 6:778b081f6a13 1075 #endif
dflet 6:778b081f6a13 1076
dflet 6:778b081f6a13 1077 private:
dflet 6:778b081f6a13 1078
dflet 6:778b081f6a13 1079 cc3100_driver &_driver;
dflet 6:778b081f6a13 1080 cc3100_nonos &_nonos;
dflet 6:778b081f6a13 1081
dflet 6:778b081f6a13 1082
dflet 6:778b081f6a13 1083 };//class
dflet 6:778b081f6a13 1084
dflet 6:778b081f6a13 1085 /*****************************************************************************/
dflet 6:778b081f6a13 1086 /* Macro declarations */
dflet 6:778b081f6a13 1087 /*****************************************************************************/
dflet 6:778b081f6a13 1088 const uint8_t FLOW_CONT_MIN = 1;
dflet 6:778b081f6a13 1089
dflet 6:778b081f6a13 1090
dflet 6:778b081f6a13 1091 class cc3100_flowcont
dflet 6:778b081f6a13 1092 {
dflet 6:778b081f6a13 1093
dflet 6:778b081f6a13 1094 public:
dflet 6:778b081f6a13 1095
dflet 6:778b081f6a13 1096 cc3100_flowcont(cc3100_driver &driver, cc3100_nonos &nonos);
dflet 6:778b081f6a13 1097
dflet 6:778b081f6a13 1098
dflet 6:778b081f6a13 1099 ~cc3100_flowcont();
dflet 6:778b081f6a13 1100
dflet 6:778b081f6a13 1101 #if 0
dflet 6:778b081f6a13 1102 /*****************************************************************************/
dflet 6:778b081f6a13 1103 /* Function prototypes */
dflet 6:778b081f6a13 1104 /*****************************************************************************/
dflet 6:778b081f6a13 1105 void _SlDrvFlowContInit(void);
dflet 6:778b081f6a13 1106 void _SlDrvFlowContDeinit(void);
dflet 6:778b081f6a13 1107 #endif
dflet 6:778b081f6a13 1108
dflet 6:778b081f6a13 1109 private:
dflet 6:778b081f6a13 1110
dflet 6:778b081f6a13 1111 cc3100_driver &_driver;
dflet 6:778b081f6a13 1112 cc3100_nonos &_nonos;
dflet 6:778b081f6a13 1113
dflet 6:778b081f6a13 1114 };//class
dflet 6:778b081f6a13 1115 }//namespace mbed_cc3100
dflet 6:778b081f6a13 1116
dflet 6:778b081f6a13 1117 /*!
dflet 6:778b081f6a13 1118
dflet 6:778b081f6a13 1119 Close the Doxygen group.
dflet 6:778b081f6a13 1120 @}
dflet 6:778b081f6a13 1121
dflet 6:778b081f6a13 1122 */
dflet 6:778b081f6a13 1123
dflet 6:778b081f6a13 1124 #endif /* __NETAPP_H__ */
dflet 6:778b081f6a13 1125
dflet 6:778b081f6a13 1126