1 /* 2 * netapp.h - CC31xx/CC32xx Host Driver Implementation 3 * 4 * Copyright (C) 2017 Texas Instruments Incorporated - http://www.ti.com/ 5 * 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions 9 * are met: 10 * 11 * Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 14 * Redistributions in binary form must reproduce the above copyright 15 * notice, this list of conditions and the following disclaimer in the 16 * documentation and/or other materials provided with the 17 * distribution. 18 * 19 * Neither the name of Texas Instruments Incorporated nor the names of 20 * its contributors may be used to endorse or promote products derived 21 * from this software without specific prior written permission. 22 * 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 * 35 */ 36 37 38 39 /*****************************************************************************/ 40 /* Include files */ 41 /*****************************************************************************/ 42 #include <ti/drivers/net/wifi/simplelink.h> 43 44 #ifndef __NETAPP_H__ 45 #define __NETAPP_H__ 46 47 48 49 50 #ifdef __cplusplus 51 extern "C" { 52 #endif 53 54 /*! 55 \defgroup NetApp 56 \short Activates networking applications, such as: HTTP Server, DHCP Server, Ping, DNS and mDNS 57 58 */ 59 60 /*! 61 62 \addtogroup NetApp 63 @{ 64 65 */ 66 67 /*****************************************************************************/ 68 /* Macro declarations */ 69 /*****************************************************************************/ 70 71 /* NetApp user events */ 72 typedef enum 73 { 74 SL_NETAPP_EVENT_IPV4_ACQUIRED = 1, 75 SL_NETAPP_EVENT_IPV6_ACQUIRED, 76 SL_NETAPP_EVENT_IP_COLLISION, 77 SL_NETAPP_EVENT_DHCPV4_LEASED, 78 SL_NETAPP_EVENT_DHCPV4_RELEASED, 79 SL_NETAPP_EVENT_HTTP_TOKEN_GET, 80 SL_NETAPP_EVENT_HTTP_TOKEN_POST, 81 SL_NETAPP_EVENT_IPV4_LOST, 82 SL_NETAPP_EVENT_DHCP_IPV4_ACQUIRE_TIMEOUT, 83 SL_NETAPP_EVENT_IPV6_LOST, 84 SL_NETAPP_EVENT_NO_IPV4_COLLISION_DETECTED, 85 SL_NETAPP_EVENT_NO_LOCAL_IPV6_COLLISION_DETECTED, 86 SL_NETAPP_EVENT_NO_GLOBAL_IPV6_COLLISION_DETECTED, 87 SL_NETAPP_EVENT_MAX 88 } SlNetAppEventId_e; 89 90 91 #define SL_NETAPP_MDNS_OPTIONS_IS_UNIQUE_BIT 0x1 92 #define SL_NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT ((_u32)0x1 << 31) 93 #define SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT ((_u32)0x1 << 30) 94 #define SL_NETAPP_MDNS_OPTION_UPDATE_TEXT ((_u32)0x1 << 29) 95 #define SL_NETAPP_MDNS_IPV4_ONLY_SERVICE (_u32)(0) /* default mode:zero bits 27,28*/ 96 #define SL_NETAPP_MDNS_IPV6_ONLY_SERVICE ((_u32)0x1 << 28) 97 #define SL_NETAPP_MDNS_IPV6_IPV4_SERVICE ((_u32)0x1 << 27) 98 99 100 /*ERROR code*/ 101 #define SL_NETAPP_RX_BUFFER_LENGTH_ERROR (-230) 102 103 /* Http Server interface */ 104 #define SL_NETAPP_MAX_INPUT_STRING (64) /* because of WPA */ 105 106 #define SL_NETAPP_MAX_AUTH_NAME_LEN (20) 107 #define SL_NETAPP_MAX_AUTH_PASSWORD_LEN (20) 108 #define SL_NETAPP_MAX_AUTH_REALM_LEN (20) 109 110 #define SL_NETAPP_MAX_DEVICE_URN_LEN (32+1) 111 #define SL_NETAPP_MAX_DOMAIN_NAME_LEN (24+1) 112 113 #define SL_NETAPP_MAX_ACTION_LEN (30) 114 #define SL_NETAPP_MAX_TOKEN_NAME_LEN (20) 115 116 117 #define SL_NETAPP_MAX_TOKEN_VALUE_LEN SL_NETAPP_MAX_INPUT_STRING 118 119 #define SL_NETAPP_MAX_SERVICE_TEXT_SIZE (256) 120 #define SL_NETAPP_MAX_SERVICE_NAME_SIZE (60) 121 #define SL_NETAPP_MAX_SERVICE_HOST_NAME_SIZE (64) 122 123 124 /* Server Responses */ 125 #define SL_NETAPP_HTTPRESPONSE_NONE (0) 126 #define SL_NETAPP_HTTPSETTOKENVALUE (1) 127 128 #define SL_NETAPP_FAMILY_MASK (0x80) 129 130 /* mDNS types */ 131 #define SL_NETAPP_MASK_IPP_TYPE_OF_SERVICE (0x00000001) 132 #define SL_NETAPP_MASK_DEVICE_INFO_TYPE_OF_SERVICE (0x00000002) 133 #define SL_NETAPP_MASK_HTTP_TYPE_OF_SERVICE (0x00000004) 134 #define SL_NETAPP_MASK_HTTPS_TYPE_OF_SERVICE (0x00000008) 135 #define SL_NETAPP_MASK_WORKSATION_TYPE_OF_SERVICE (0x00000010) 136 #define SL_NETAPP_MASK_GUID_TYPE_OF_SERVICE (0x00000020) 137 #define SL_NETAPP_MASK_H323_TYPE_OF_SERVICE (0x00000040) 138 #define SL_NETAPP_MASK_NTP_TYPE_OF_SERVICE (0x00000080) 139 #define SL_NETAPP_MASK_OBJECITVE_TYPE_OF_SERVICE (0x00000100) 140 #define SL_NETAPP_MASK_RDP_TYPE_OF_SERVICE (0x00000200) 141 #define SL_NETAPP_MASK_REMOTE_TYPE_OF_SERVICE (0x00000400) 142 #define SL_NETAPP_MASK_RTSP_TYPE_OF_SERVICE (0x00000800) 143 #define SL_NETAPP_MASK_SIP_TYPE_OF_SERVICE (0x00001000) 144 #define SL_NETAPP_MASK_SMB_TYPE_OF_SERVICE (0x00002000) 145 #define SL_NETAPP_MASK_SOAP_TYPE_OF_SERVICE (0x00004000) 146 #define SL_NETAPP_MASK_SSH_TYPE_OF_SERVICE (0x00008000) 147 #define SL_NETAPP_MASK_TELNET_TYPE_OF_SERVICE (0x00010000) 148 #define SL_NETAPP_MASK_TFTP_TYPE_OF_SERVICE (0x00020000) 149 #define SL_NETAPP_MASK_XMPP_CLIENT_TYPE_OF_SERVICE (0x00040000) 150 #define SL_NETAPP_MASK_RAOP_TYPE_OF_SERVICE (0x00080000) 151 #define SL_NETAPP_MASK_ALL_TYPE_OF_SERVICE (0xFFFFFFFF) 152 153 /********************************************************************************************************/ 154 155 /* NetApp application IDs */ 156 #define SL_NETAPP_HTTP_SERVER_ID (0x01) 157 #define SL_NETAPP_DHCP_SERVER_ID (0x02) 158 #define SL_NETAPP_MDNS_ID (0x04) 159 #define SL_NETAPP_DNS_SERVER_ID (0x08) 160 161 #define SL_NETAPP_DEVICE_ID (0x10) 162 #define SL_NETAPP_DNS_CLIENT_ID (0x20) 163 #define SL_NETAPP_STATUS (0x40) 164 165 /* NetApp application set/get options */ 166 #define SL_NETAPP_DHCP_SRV_BASIC_OPT (0) 167 168 /* HTTP server set/get options */ 169 #define SL_NETAPP_HTTP_PRIMARY_PORT_NUMBER (0) 170 #define SL_NETAPP_HTTP_AUTH_CHECK (1) 171 #define SL_NETAPP_HTTP_AUTH_NAME (2) 172 #define SL_NETAPP_HTTP_AUTH_PASSWORD (3) 173 #define SL_NETAPP_HTTP_AUTH_REALM (4) 174 #define SL_NETAPP_HTTP_ROM_PAGES_ACCESS (5) 175 #define SL_NETAPP_HTTP_SECONDARY_PORT_NUMBER (6) 176 #define SL_NETAPP_HTTP_SECONDARY_PORT_ENABLE (7) /*Enable / disable of secondary port */ 177 #define SL_NETAPP_HTTP_PRIMARY_PORT_SECURITY_MODE (8) 178 #define SL_NETAPP_HTTP_PRIVATE_KEY_FILENAME (9) 179 #define SL_NETAPP_HTTP_DEVICE_CERTIFICATE_FILENAME (10) 180 #define SL_NETAPP_HTTP_CA_CERTIFICATE_FILE_NAME (11) 181 #define SL_NETAPP_HTTP_TEMP_REGISTER_MDNS_SERVICE_NAME (12) 182 #define SL_NETAPP_HTTP_TEMP_UNREGISTER_MDNS_SERVICE_NAME (13) 183 #define SL_NETAPP_HTTP_TIMEOUT (14) 184 185 186 #define SL_NETAPP_MDNS_CONT_QUERY_OPT (1) 187 #define SL_NETAPP_MDNS_QEVETN_MASK_OPT (2) 188 #define SL_NETAPP_MDNS_TIMING_PARAMS_OPT (3) 189 190 /* DNS server set/get options */ 191 #define SL_NETAPP_DNS_OPT_DOMAIN_NAME (0) 192 193 /* Device Config set/get options */ 194 #define SL_NETAPP_DEVICE_URN (0) 195 #define SL_NETAPP_DEVICE_DOMAIN (1) 196 #define SL_NETAPP_DEVICE_NAME (2) 197 198 /* DNS client set/get options */ 199 #define SL_NETAPP_DNS_CLIENT_TIME (0) 200 #define SL_NETAPP_DNS_CLIENT_CACHE_CLEAR (1) 201 #define SL_NETAPP_DNS_CLIENT_CACHE_ENABLE (2) 202 203 /* Get active application bimap */ 204 #define SL_NETAPP_STATUS_ACTIVE_APP (0) 205 206 #define SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH (255) 207 208 209 /*****************************************************************************/ 210 /* Structure/Enum declarations */ 211 /*****************************************************************************/ 212 213 typedef struct 214 { 215 _u32 Ip; 216 _u32 Gateway; 217 _u32 Dns; 218 }SlIpV4AcquiredAsync_t; 219 220 typedef enum 221 { 222 SL_BSD_IPV6_ACQUIRED_TYPE_LOCAL = 1, 223 SL_BSD_IPV6_ACQUIRED_TYPE_GLOBAL = 2 224 }SlIpV6AcquiredAsyncType_e; 225 226 typedef struct 227 { 228 _u32 Ip[4]; 229 _u32 Dns[4]; 230 }SlIpV6AcquiredAsync_t; 231 232 typedef struct 233 { 234 _u32 IpAddress; 235 _u32 LeaseTime; 236 _u8 Mac[6]; 237 _u16 Padding; 238 }SlIpLeasedAsync_t; 239 240 typedef struct 241 { 242 _u32 IpAddress; 243 _u8 Mac[6]; 244 _u16 Reason; 245 }SlIpReleasedAsync_t; 246 247 typedef struct 248 { 249 _u32 IpAddress; 250 _u8 DhcpMac[6]; 251 _u8 ConflictMac[6]; 252 }SlIpCollisionAsync_t; 253 254 typedef struct 255 { 256 _u32 Ip; 257 _u8 Mac[6]; 258 _u16 AddMode; 259 }SlNoIpV4CollisionDetectedAsync_t; 260 261 typedef struct 262 { 263 _u32 Ip[4]; 264 _u8 Mac[6]; 265 _u16 AddMode; 266 }SlNoIpV6CollisionDetectedAsync_t; 267 268 269 270 typedef struct 271 { 272 _i16 Status; 273 _u16 Padding; 274 }SlIpV4Lost_t; 275 276 typedef struct 277 { 278 _u32 IpLost[4]; 279 }SlIpV6Lost_t; 280 281 typedef struct 282 { 283 _i16 Status; 284 _u16 Padding; 285 }SlDhcpIpAcquireTimeout_t; 286 287 typedef union 288 { 289 SlIpV4AcquiredAsync_t IpAcquiredV4; /* SL_NETAPP_EVENT_IPV4_ACQUIRED */ 290 SlIpV6AcquiredAsync_t IpAcquiredV6; /* SL_NETAPP_EVENT_IPV6_ACQUIRED */ 291 _u32 Sd; /* SL_SOCKET_TX_FAILED_EVENT */ 292 SlIpLeasedAsync_t IpLeased; /* SL_NETAPP_EVENT_DHCPV4_LEASED */ 293 SlIpReleasedAsync_t IpReleased; /* SL_NETAPP_EVENT_DHCPV4_RELEASED */ 294 SlIpV4Lost_t IpV4Lost; /* SL_NETAPP_EVENT_IPV4_LOST */ 295 SlDhcpIpAcquireTimeout_t DhcpIpAcquireTimeout; /* SL_NETAPP_DHCP_ACQUIRE_IPV4_TIMEOUT_EVENT */ 296 SlIpCollisionAsync_t IpCollision; /* SL_NETAPP_EVENT_IP_COLLISION */ 297 SlIpV6Lost_t IpV6Lost; /* SL_NETAPP_EVENT_IPV6_LOST */ 298 SlNoIpV4CollisionDetectedAsync_t Ipv4CollisionDetected; /* SL_NETAPP_EVENT_NO_IPV4_COLLISION_DETECTED */ 299 SlNoIpV6CollisionDetectedAsync_t Ipv6CollisionDetected; /* SL_NETAPP_EVENT_NO_IPV4_COLLISION_DETECTED */ 300 } SlNetAppEventData_u; 301 302 typedef struct 303 { 304 _u32 Id; 305 SlNetAppEventData_u Data; 306 }SlNetAppEvent_t; 307 308 typedef struct 309 { 310 _u32 PacketsSent; 311 _u32 PacketsReceived; 312 _u16 MinRoundTime; 313 _u16 MaxRoundTime; 314 _u16 AvgRoundTime; 315 _u32 TestTime; 316 }SlNetAppPingReport_t; 317 318 typedef struct 319 { 320 _u32 PingIntervalTime; /* delay between pings, in milliseconds */ 321 _u16 PingSize; /* ping packet size in bytes */ 322 _u16 PingRequestTimeout; /* timeout time for every ping in milliseconds */ 323 _u32 TotalNumberOfAttempts; /* max number of ping requests. 0 - forever */ 324 _u32 Flags; /* flag - 0 report only when finished, 1 - return response for every ping, 2 - stop after 1 successful ping. 4 - ipv4 header flag - don`t fragment packet */ 325 _u32 Ip; /* IPv4 address or IPv6 first 4 bytes */ 326 _u32 Ip1OrPadding; 327 _u32 Ip2OrPadding; 328 _u32 Ip3OrPadding; 329 }SlNetAppPingCommand_t; 330 331 typedef struct 332 { 333 _u8 Len; 334 _u8 *pData; 335 } SlNetAppHttpServerString_t; 336 337 typedef struct 338 { 339 _u8 ValueLen; 340 _u8 NameLen; 341 _u8 *pTokenValue; 342 _u8 *pTokenName; 343 } SlNetAppHttpServerData_t; 344 345 typedef struct 346 { 347 SlNetAppHttpServerString_t Action; 348 SlNetAppHttpServerString_t TokenName; 349 SlNetAppHttpServerString_t TokenValue; 350 }SlNetAppHttpServerPostData_t; 351 352 typedef union 353 { 354 SlNetAppHttpServerString_t HttpTokenName; /* SL_NETAPP_HTTPGETTOKENVALUE */ 355 SlNetAppHttpServerPostData_t HttpPostData; /* SL_NETAPP_HTTPPOSTTOKENVALUE */ 356 } SlNetAppHttpServerEventData_u; 357 358 typedef union 359 { 360 SlNetAppHttpServerString_t TokenValue; 361 } SlNetAppHttpServerResponsedata_u; 362 363 typedef struct 364 { 365 _u32 Event; 366 SlNetAppHttpServerEventData_u EventData; 367 }SlNetAppHttpServerEvent_t; 368 369 typedef struct 370 { 371 _u32 Response; 372 SlNetAppHttpServerResponsedata_u ResponseData; 373 }SlNetAppHttpServerResponse_t; 374 375 /***************************************************************************************** 376 * NETAPP Request/Response/Send/Receive 377 ******************************************************************************************/ 378 /* TODO: check what definitions are eventually needed */ 379 /* NETAPP http request types */ 380 #define SL_NETAPP_REQUEST_HTTP_GET 1 381 #define SL_NETAPP_REQUEST_HTTP_POST 2 382 #define SL_NETAPP_REQUEST_HTTP_PUT 3 383 #define SL_NETAPP_REQUEST_HTTP_DELETE 4 384 385 #define SL_NETAPP_REQUEST_MAX_METADATA_LEN 1024 386 #define SL_NETAPP_REQUEST_MAX_DATA_LEN 1364 /* Metadata + Payload */ 387 388 389 typedef enum 390 { 391 SL_NETAPP_REQUEST_METADATA_TYPE_STATUS = 0, 392 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_VERSION, 393 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_REQUEST_URI, 394 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_QUERY_STRING, 395 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONTENT_LEN, 396 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONTENT_TYPE, 397 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_LOCATION, 398 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_SERVER, 399 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_USER_AGENT, 400 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_COOKIE, 401 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_SET_COOKIE, 402 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_UPGRADE, 403 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_REFERER, 404 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_ACCEPT, 405 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONTENT_ENCODING, 406 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONTENT_DISPOSITION, 407 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_CONNECTION, 408 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_ETAG, 409 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_DATE, 410 SL_NETAPP_REQUEST_METADATA_TYPE_HEADER_HOST, 411 SL_NETAPP_REQUEST_METADATA_TYPE_ACCEPT_ENCODING, 412 SL_NETAPP_REQUEST_METADATA_TYPE_ACCEPT_LANGUAGE, 413 SL_NETAPP_REQUEST_METADATA_TYPE_CONTENT_LANGUAGE, 414 SL_NETAPP_REQUEST_METADATA_TYPE_ORIGIN, 415 SL_NETAPP_REQUEST_METADATA_TYPE_ORIGIN_CONTROL_ACCESS, 416 SL_NETAPP_REQUEST_METADATA_TYPE_HTTP_NONE 417 } SlNetAppMetadataHTTPTypes_e; 418 419 typedef enum 420 { 421 SL_NETAPP_RESPONSE_NONE = 0, /* No response */ 422 SL_NETAPP_RESPONSE_PENDING = 1, /* status will arrive in future NetApp Send call (in metadata) */ 423 424 SL_NETAPP_HTTP_RESPONSE_101_SWITCHING_PROTOCOLS = 101, /* 101 Switching Protocol*/ 425 SL_NETAPP_HTTP_RESPONSE_200_OK = 200, /* 200 OK */ 426 SL_NETAPP_HTTP_RESPONSE_201_CREATED = 201, /* "HTTP/1.0 201 Created" */ 427 SL_NETAPP_HTTP_RESPONSE_202_ACCEPTED = 202, /* "HTTP/1.0 202 Accepted" */ 428 SL_NETAPP_HTTP_RESPONSE_204_OK_NO_CONTENT = 204, /* 204 No Content */ 429 SL_NETAPP_HTTP_RESPONSE_301_MOVED_PERMANENTLY = 301, /* "HTTP/1.0 301 Moved Permanently" */ 430 SL_NETAPP_HTTP_RESPONSE_302_MOVED_TEMPORARILY = 302, /* 302 Moved Temporarily (http 1.0) */ 431 SL_NETAPP_HTTP_RESPONSE_303_SEE_OTHER = 303, /* "HTTP/1.1 303 See Other" */ 432 SL_NETAPP_HTTP_RESPONSE_304_NOT_MODIFIED = 304, /* "HTTP/1.0 304 Not Modified" */ 433 SL_NETAPP_HTTP_RESPONSE_400_BAD_REQUEST = 400, /* "HTTP/1.0 400 Bad Request" */ 434 SL_NETAPP_HTTP_RESPONSE_403_FORBIDDEN = 403, /* "HTTP/1.0 403 Forbidden" */ 435 SL_NETAPP_HTTP_RESPONSE_404_NOT_FOUND = 404, /* 404 Not Found */ 436 SL_NETAPP_HTTP_RESPONSE_405_METHOD_NOT_ALLOWED = 405, /* "HTTP/1.0 405 Method Not Allowed" */ 437 SL_NETAPP_HTTP_RESPONSE_500_INTERNAL_SERVER_ERROR = 500, /* 500 Internal Server Error */ 438 SL_NETAPP_HTTP_RESPONSE_503_SERVICE_UNAVAILABLE = 503, /* "HTTP/1.0 503 Service Unavailable" */ 439 SL_NETAPP_HTTP_RESPONSE_504_GATEWAY_TIMEOUT = 504 /* "HTTP/1.0 504 Gateway Timeout" */ 440 } SlNetAppResponseCode_e; 441 442 443 #define SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION 0x00000001 444 #define SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA 0x00000002 /* 0 - data is payload, 1 - data is metadata */ 445 #define SL_NETAPP_REQUEST_RESPONSE_FLAGS_ACCUMULATION 0x00000004 446 #define SL_NETAPP_REQUEST_RESPONSE_FLAGS_ERROR 0x80000000 /* in that case the last two bytes represents the error code */ 447 448 typedef struct 449 { 450 _u16 MetadataLen; 451 _u8 *pMetadata; 452 _u16 PayloadLen; 453 _u8 *pPayload; 454 _u32 Flags; 455 } SlNetAppData_t; 456 457 typedef struct 458 { 459 _u8 AppId; 460 _u8 Type; 461 _u16 Handle; 462 SlNetAppData_t requestData; 463 } SlNetAppRequest_t; 464 465 typedef struct 466 { 467 _u16 Status; 468 SlNetAppData_t ResponseData; 469 } SlNetAppResponse_t; 470 471 typedef struct 472 { 473 _u32 lease_time; 474 _u32 ipv4_addr_start; 475 _u32 ipv4_addr_last; 476 }SlNetAppDhcpServerBasicOpt_t; 477 478 /* mDNS parameters */ 479 typedef enum 480 { 481 SL_NETAPP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE = 1, 482 SL_NETAPP_FULL_SERVICE_IPV4_TYPE, 483 SL_NETAPP_SHORT_SERVICE_IPV4_TYPE, 484 SL_NETAPP_FULL_SERVICE_WITH_TEXT_IPV6_TYPE , 485 SL_NETAPP_FULL_SERVICE_IPV6_TYPE, 486 SL_NETAPP_SHORT_SERVICE_IPV6_TYPE 487 } SlNetAppGetServiceListType_e; 488 489 typedef struct 490 { 491 _u32 service_ipv4; 492 _u16 service_port; 493 _u16 Reserved; 494 }SlNetAppGetShortServiceIpv4List_t; 495 496 typedef struct 497 { 498 _u32 service_ipv4; 499 _u16 service_port; 500 _u16 Reserved; 501 _u8 service_name[SL_NETAPP_MAX_SERVICE_NAME_SIZE]; 502 _u8 service_host[SL_NETAPP_MAX_SERVICE_HOST_NAME_SIZE]; 503 }SlNetAppGetFullServiceIpv4List_t; 504 505 typedef struct 506 { 507 _u32 service_ipv4; 508 _u16 service_port; 509 _u16 Reserved; 510 _u8 service_name[SL_NETAPP_MAX_SERVICE_NAME_SIZE]; 511 _u8 service_host[SL_NETAPP_MAX_SERVICE_HOST_NAME_SIZE]; 512 _u8 service_text[SL_NETAPP_MAX_SERVICE_TEXT_SIZE]; 513 }SlNetAppGetFullServiceWithTextIpv4List_t; 514 515 /* IPv6 entries */ 516 typedef struct 517 { 518 _u32 service_ipv6[4]; 519 _u16 service_port; 520 _u16 Reserved; 521 }SlNetAppGetShortServiceIpv6List_t; 522 523 typedef struct 524 { 525 _u32 service_ipv6[4]; 526 _u16 service_port; 527 _u16 Reserved; 528 _u8 service_name[SL_NETAPP_MAX_SERVICE_NAME_SIZE]; 529 _u8 service_host[SL_NETAPP_MAX_SERVICE_HOST_NAME_SIZE]; 530 }SlNetAppGetFullServiceIpv6List_t; 531 532 typedef struct 533 { 534 _u32 service_ipv6[4]; 535 _u16 service_port; 536 _u16 Reserved; 537 _u8 service_name[SL_NETAPP_MAX_SERVICE_NAME_SIZE]; 538 _u8 service_host[SL_NETAPP_MAX_SERVICE_HOST_NAME_SIZE]; 539 _u8 service_text[SL_NETAPP_MAX_SERVICE_TEXT_SIZE]; 540 }SlNetAppGetFullServiceWithTextIpv6List_t; 541 542 typedef struct 543 { 544 /*The below parameters are used to configure the advertise times and interval 545 For example: 546 If: 547 Period is set to T 548 Repetitions are set to P 549 Telescopic factor is K=2 550 The transmission shall be: 551 advertise P times 552 wait T 553 advertise P times 554 wait 4 * T 555 advertise P time 556 wait 16 * T ... (till max time reached / configuration changed / query issued) 557 */ 558 _u32 t; /* Number of ticks for the initial period. Default is 100 ticks for 1 second. */ 559 _u32 p; /* Number of repetitions. Default value is 1 */ 560 _u32 k; /* Telescopic factor. Default value is 2. */ 561 _u32 RetransInterval; /* Announcing retransmission interval */ 562 _u32 Maxinterval; /* Announcing max period interval */ 563 _u32 max_time; /* Announcing max time */ 564 }SlNetAppServiceAdvertiseTimingParameters_t; 565 566 typedef struct 567 { 568 _u16 MaxResponseTime; 569 _u16 NumOfRetries; 570 }SlNetAppDnsClientTime_t; 571 572 /*****************************************************************************/ 573 /* Types declarations */ 574 /*****************************************************************************/ 575 typedef void (*P_SL_DEV_PING_CALLBACK)(SlNetAppPingReport_t*); 576 577 /*****************************************************************************/ 578 /* Function prototypes */ 579 /*****************************************************************************/ 580 581 582 /*! 583 \brief Starts a network application 584 585 Gets and starts network application for the current WLAN mode 586 587 \param[in] AppBitMap Application bitmap, could be one or combination of the following: 588 - SL_NETAPP_HTTP_SERVER_ID 589 - SL_NETAPP_DHCP_SERVER_ID 590 - SL_NETAPP_MDNS_ID 591 - SL_NETAPP_DNS_SERVER_ID 592 593 \par Persistent - <b>System Persistent</b> 594 \return Zero on success, or negative error code on failure 595 596 \sa sl_NetAppStop 597 \note This command activates the application for the current WLAN mode (AP or STA) 598 \warning 599 \par Example 600 601 - Starting internal HTTP server + DHCP server: 602 \code 603 sl_NetAppStart(SL_NETAPP_HTTP_SERVER_ID | SL_NETAPP_DHCP_SERVER_ID) 604 \endcode 605 */ 606 #if _SL_INCLUDE_FUNC(sl_NetAppStart) 607 _i16 sl_NetAppStart(const _u32 AppBitMap); 608 #endif 609 /*! 610 \brief Stops a network application 611 612 Gets and stops network application for the current WLAN mode 613 614 \param[in] AppBitMap Application id, could be one of the following: \n 615 - SL_NETAPP_HTTP_SERVER_ID 616 - SL_NETAPP_DHCP_SERVER_ID 617 - SL_NETAPP_MDNS_ID 618 - SL_NETAPP_DNS_SERVER_ID 619 620 \par Persistent - <b>System Persistent</b> 621 622 \return Zero on success, or nagative error code on failure 623 624 \sa sl_NetAppStart 625 \note This command disables the application for the current active WLAN mode (AP or STA) 626 \warning 627 \par Example 628 629 - Stopping internal HTTP server: 630 \code 631 sl_NetAppStop(SL_NETAPP_HTTP_SERVER_ID); 632 \endcode 633 */ 634 #if _SL_INCLUDE_FUNC(sl_NetAppStop) 635 _i16 sl_NetAppStop(const _u32 AppBitMap); 636 #endif 637 638 /*! 639 \brief Flush IPv4 ARP table 640 641 642 643 \param[in] None \n 644 645 646 \return Zero on success, or negative error code on failure 647 648 \sa sl_NetAppArpFlush 649 \note This command flush IPv4 ARP table 650 \warning 651 \par Example 652 653 654 \code 655 sl_NetAppArpFlush(); 656 \endcode 657 */ 658 #if _SL_INCLUDE_FUNC(sl_NetAppArpFlush) 659 _i16 sl_NetAppArpFlush(); 660 #endif 661 662 /*! 663 \brief Flush IPv6 Neighbor Discovery table 664 665 666 667 \param[in] None \n 668 669 670 \return Zero on success, or negative error code on failure 671 672 \sa sl_NetAppNdFlush 673 \note This command flush IPv6 Neighbor Discovery table 674 \warning 675 \par Example 676 677 678 \code 679 sl_NetAppNdFlush(); 680 \endcode 681 */ 682 #if _SL_INCLUDE_FUNC(sl_NetAppNdFlush) 683 _i16 sl_NetAppNdFlush(); 684 #endif 685 686 /*! 687 \brief Get host IP by name\n 688 Obtain the IP Address of machine on network, by machine name. 689 690 \param[in] pHostName Host name 691 \param[in] NameLen Name length 692 \param[out] OutIpAddr This parameter is filled in with 693 host IP address. In case that host name is not 694 resolved, out_ip_addr is zero. 695 \param[in] Family Protocol family 696 697 \return Zero on success, or negative on failure.\n 698 SL_POOL_IS_EMPTY may be return in case there are no resources in the system\n 699 In this case try again later or increase MAX_CONCURRENT_ACTIONS 700 Possible DNS error codes: 701 - SL_NETAPP_DNS_QUERY_NO_RESPONSE 702 - SL_NETAPP_DNS_NO_SERVER 703 - SL_NETAPP_DNS_QUERY_FAILED 704 - SL_NETAPP_DNS_MALFORMED_PACKET 705 - SL_NETAPP_DNS_MISMATCHED_RESPONSE 706 707 \sa 708 \note Only one sl_NetAppDnsGetHostByName can be handled at a time.\n 709 Calling this API while the same command is called from another thread, may result 710 in one of the two scenarios: 711 1. The command will wait (internal) until the previous command finish, and then be executed. 712 2. There are not enough resources and POOL_IS_EMPTY error will return.\n 713 In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try 714 again later to issue the command. 715 \warning 716 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 717 try to access the DNS and it will return the input address on the 'out_ip_addr' field 718 \par Example 719 720 - Getting host by name: 721 \code 722 _u32 DestinationIP; 723 _u32 AddrSize; 724 _i16 SockId; 725 SlSockAddrIn_t Addr; 726 727 sl_NetAppDnsGetHostByName("www.google.com", strlen("www.google.com"), &DestinationIP,SL_AF_INET); 728 729 Addr.sin_family = SL_AF_INET; 730 Addr.sin_port = sl_Htons(80); 731 Addr.sin_addr.s_addr = sl_Htonl(DestinationIP); 732 AddrSize = sizeof(SlSockAddrIn_t); 733 SockId = sl_Socket(SL_AF_INET,SL_SOCK_STREAM, 0); 734 \endcode 735 */ 736 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByName) 737 _i16 sl_NetAppDnsGetHostByName(_i8 * pHostName,const _u16 NameLen, _u32* OutIpAddr,const _u8 Family ); 738 #endif 739 740 /*! 741 \brief Return service attributes like IP address, port and text according to service name\n 742 The user sets a service name Full/Part (see example below), and should get: 743 - IP of service 744 - The port of service 745 - The text of service 746 Hence it can make a connection to the specific service and use it. 747 It is similar to sl_NetAppDnsGetHostByName method.\n 748 It is done by a single shot ipv4 & ipv6 (if enabled) query with PTR type on the service name. 749 The command that is sent is from constant parameters and variables parameters. 750 751 \param[in] pServiceName Service name can be full or partial. \n 752 Example for full service name: 753 1. PC1._ipp._tcp.local 754 2. PC2_server._ftp._tcp.local \n 755 . 756 Example for partial service name: 757 1. _ipp._tcp.local 758 2. _ftp._tcp.local 759 760 \param[in] ServiceLen The length of the service name (in_pService). 761 \param[in] Family IPv4 or IPv6 (SL_AF_INET , SL_AF_INET6). 762 \param[out] pAddr Contains the IP address of the service. 763 \param[out] pPort Contains the port of the service. 764 \param[out] pTextLen Has 2 options. One as Input field and the other one as output: 765 - Input: \n 766 Contains the max length of the text that the user wants to get.\n 767 It means that if the text len of service is bigger that its value than 768 the text is cut to inout_TextLen value. 769 - Output: \n 770 Contain the length of the text that is returned. Can be full text or part of the text (see above). 771 772 \param[out] pText Contains the text of the service full or partial 773 774 \return Zero on success,\n 775 SL_POOL_IS_EMPTY may be return in case there are no resources in the system, 776 In this case try again later or increase MAX_CONCURRENT_ACTIONS\n 777 In case No service is found error SL_NETAPP_DNS_NO_ANSWER will be returned 778 \sa sl_NetAppDnsGetHostByName 779 \note The returns attributes belongs to the first service found. 780 There may be other services with the same service name that will response to the query. 781 The results of these responses are saved in the peer cache of the Device and should be read by another API.\n 782 783 Only one sl_NetAppDnsGetHostByService can be handled at a time.\n 784 Calling this API while the same command is called from another thread, may result 785 in one of the two scenarios: 786 1. The command will wait (internal) until the previous command finish, and then be executed. 787 2. There are not enough resources and SL_POOL_IS_EMPTY error will return. 788 In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try 789 again later to issue the command. 790 791 \warning Text length can be 120 bytes only 792 */ 793 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByService) 794 _i16 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all (or only part): name + subtype + service */ 795 const _u8 ServiceLen, 796 const _u8 Family, /* 4-IPv4 , 16-IPv6 */ 797 _u32 pAddr[], 798 _u32 *pPort, 799 _u16 *pTextLen, /* in: max len , out: actual len */ 800 _i8 *pText 801 ); 802 803 #endif 804 805 /*! 806 \brief Get service list\n 807 Insert into out pBuffer a list of peer's services that are in the NWP without issuing any queries (relying on previous collected data).\n 808 The list is in a form of service struct. The user should chose the type 809 of the service struct like: 810 - Full service parameters with text. 811 - Full service parameters. 812 - Short service parameters (port and IP only) especially for tiny hosts. 813 814 The different types of struct are made to give the 815 possibility to save memory in the host.\n 816 817 The user can also chose how many max services to get and start point index 818 NWP peer cache.\n 819 For example: 820 1. Get max of 3 full services from index 0. 821 - Up to 3 full services from index 0 are inserted into pBuffer (services that are in indexes 0,1,2). 822 2. Get max of 4 full services from index 3. 823 - Up to 4 full services from index 3 are inserted into pBuffer (services that are in indexes 3,4,5,6). 824 3. Get max of 2 int services from index 6. 825 - Up to 2 int services from index 6 are inserted into pBuffer (services that are in indexes 6,7). 826 See below - command parameters. 827 828 \param[in] IndexOffset - The start index in the peer cache that from it the first service is returned. 829 \param[in] MaxServiceCount - The Max services that can be returned if existed or if not exceed the max index 830 in the peer cache 831 \param[in] Flags - an ENUM number that means which service struct to use (means which types of service to fill) 832 - use SL_NETAPP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE for SlNetAppGetFullServiceWithTextIpv4List_t 833 - use SL_NETAPP_FULL_SERVICE_IPV4_TYPE for SlNetAppGetFullServiceIpv4List_t 834 - use SL_NETAPP_SHORT_SERVICE_IPV4_TYP SlNetAppGetShortServiceIpv4List_t 835 - use SL_NETAPP_FULL_SERVICE_IPV6_TYPE, SlNetAppGetFullServiceIpv6List_t 836 - use SL_NETAPP_SHORT_SERVICE_IPV6_TYPE SlNetAppGetShortServiceIpv6List_t 837 - use SL_NETAPP_FULL_SERVICE_WITH_TEXT_IPV6_TYPE SlNetAppGetFullServiceWithTextIpv6List_t 838 839 \param[out] pBuffer - The Services are inserted into this buffer. In the struct form according to the bit that is set in the Flags 840 input parameter. 841 842 \param[in] BufferLength - The allocated buffer length (pointed by pBuffer). 843 844 \return ServiceFoundCount - The number of the services that were inserted into the buffer.\n 845 Zero means no service is found negative number means an error 846 \sa sl_NetAppMDNSRegisterService 847 \note 848 \warning 849 If the out pBuffer size is bigger than an RX packet(1480), than 850 an error is returned because there is no place in the RX packet.\n 851 The size is a multiply of MaxServiceCount and size of service struct(that is set 852 according to flag value). 853 */ 854 855 #if _SL_INCLUDE_FUNC(sl_NetAppGetServiceList) 856 _i16 sl_NetAppGetServiceList(const _u8 IndexOffset, 857 const _u8 MaxServiceCount, 858 const _u8 Flags, 859 _i8 *pBuffer, 860 const _u32 BufferLength 861 ); 862 863 #endif 864 865 /*! 866 \brief Unregister mDNS service\n 867 This function deletes the mDNS service from the mDNS package and the database. 868 869 The mDNS service that is to be unregistered is a service that the application no longer wishes to provide. \n 870 The service name should be the full service name according to RFC 871 of the DNS-SD - meaning the value in name field in the SRV answer. 872 873 Examples for service names: 874 1. PC1._ipp._tcp.local 875 2. PC2_server._ftp._tcp.local 876 877 \param[in] pServiceName Full service name. \n 878 \param[in] ServiceNameLen The length of the service. 879 \param[in] Options bitwise parameters: \n 880 - SL_NETAPP_MDNS_OPTIONS_IS_UNIQUE_BIT bit 0 - service is unique per interface (means that the service needs to be unique) 881 - SL_NETAPP_MDNS_IPV6_IPV4_SERVICE bit 27 - add this service to IPv6 interface, if exist (default is IPv4 service only) 882 - SL_NETAPP_MDNS_IPV6_ONLY_SERVICE bit 28 - add this service to IPv6 interface, but remove it from IPv4 (only IPv6 is available) 883 - SL_NETAPP_MDNS_OPTION_UPDATE_TEXT bit 29 - for update text fields (without reregister the service) 884 - SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT bit 30 - for setting a non persistent service 885 - SL_NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT bit 31 - for internal use if the service should be added or deleted (set means ADD). 886 887 \return Zero on success, or negative error code on failure 888 \par Persistent - <b>Optionally persistent</b> 889 \sa sl_NetAppMDNSRegisterService 890 \note 891 \warning 892 The size of the service length should be smaller than 255. 893 */ 894 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService) 895 _i16 sl_NetAppMDNSUnRegisterService(const _i8 *pServiceName,const _u8 ServiceNameLen,_u32 Options); 896 #endif 897 898 /*! 899 \brief Register a new mDNS service\n 900 This function registers a new mDNS service to the mDNS package and the DB. \n 901 This registered service is a service offered by the application. 902 The service name should be full service name according to RFC 903 of the DNS-SD - meaning the value in name field in the SRV answer.\n 904 Example for service name: 905 1. PC1._ipp._tcp.local 906 2. PC2_server._ftp._tcp.local 907 908 If the option is_unique is set, mDNS probes the service name to make sure 909 it is unique before starting to announce the service on the network. 910 Instance is the instance portion of the service name. 911 912 \param[in] ServiceNameLen The length of the service. 913 \param[in] TextLen The length of the service should be smaller than 64. 914 \param[in] Port The port on this target host port. 915 \param[in] TTL The TTL of the service 916 \param[in] Options bitwise parameters: \n 917 - SL_NETAPP_MDNS_OPTIONS_IS_UNIQUE_BIT bit 0 - service is unique per interface (means that the service needs to be unique) 918 - SL_NETAPP_MDNS_IPV6_IPV4_SERVICE bit 27 - add this service to IPv6 interface, if exist (default is IPv4 service only) 919 - SL_NETAPP_MDNS_IPV6_ONLY_SERVICE bit 28 - add this service to IPv6 interface, but remove it from IPv4 (only IPv6 is available) 920 - SL_NETAPP_MDNS_OPTION_UPDATE_TEXT bit 29 - for update text fields (without reregister the service) 921 - SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT bit 30 - for setting a non persistent service 922 - SL_NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT bit 31 - for internal use if the service should be added or deleted (set means ADD). 923 924 \param[in] pServiceName The service name. 925 \param[in] pText The description of the service. 926 should be as mentioned in the RFC 927 (according to type of the service IPP,FTP...) 928 929 \return Zero on success, or negative error code on failure 930 931 \par Persistent - <b>Optionally persistent</b> 932 933 \sa sl_NetAppMDNSUnRegisterService 934 935 \warning 1) Temporary - there is an allocation on stack of internal buffer. 936 Its size is SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH. \n 937 It means that the sum of the text length and service name length cannot be bigger than 938 SL_NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.\n 939 If it is - An error is returned. \n 940 2) According to now from certain constraints the variables parameters are set in the 941 attribute part (contain constant parameters) 942 943 \par Examples: 944 945 - Register a new service: 946 \code 947 const signed char AddService[40] = "PC1._ipp._tcp.local"; 948 _u32 Options; 949 950 Options = SL_NETAPP_MDNS_OPTIONS_IS_UNIQUE_BIT | SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT; 951 sl_NetAppMDNSRegisterService(AddService,sizeof(AddService),"Service 1;payper=A3;size=5",strlen("Service 1;payper=A3;size=5"),1000,120,Options); 952 \endcode 953 <br> 954 955 - Update text for existing service: 956 \code 957 Please Note! Update is for text only! Important to apply the same persistent flag options as original service registration.\n 958 959 Options = SL_NETAPP_MDNS_OPTION_UPDATE_TEXT | SL_NETAPP_MDNS_OPTIONS_IS_NOT_PERSISTENT; 960 sl_NetAppMDNSRegisterService(AddService,sizeof(AddService),"Service 5;payper=A4;size=10",strlen("Service 5;payper=A4;size=10"),1000,120,Options); 961 \endcode 962 */ 963 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService) 964 _i16 sl_NetAppMDNSRegisterService( const _i8* pServiceName, 965 const _u8 ServiceNameLen, 966 const _i8* pText, 967 const _u8 TextLen, 968 const _u16 Port, 969 const _u32 TTL, 970 _u32 Options); 971 #endif 972 973 /*! 974 \brief send ICMP ECHO_REQUEST to network hosts 975 976 Ping uses the ICMP protocol's mandatory ECHO_REQUEST 977 978 \param[in] pPingParams Pointer to the ping request structure: 979 - If flags parameter is set to 0, ping will report back once all requested pings are done (as defined by TotalNumberOfAttempts). 980 - If flags parameter is set to 1, ping will report back after every ping, for TotalNumberOfAttempts. 981 - 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. \n 982 - If flags parameter is set to 4, for ipv4 - don`t fragment the ping packet. This flag can be set with other flags. 983 For stopping an ongoing ping activity, set parameters IP address to 0 984 \param[in] Family SL_AF_INET or SL_AF_INET6 985 \param[out] pReport Ping pReport 986 \param[out] pPingCallback Callback function upon completion.\n 987 If callback is NULL, the API is blocked until data arrives 988 989 \return Zero on success, or negative error code on failure.\n 990 SL_POOL_IS_EMPTY may be return in case there are no resources in the system 991 In this case try again later or increase MAX_CONCURRENT_ACTIONS 992 993 \sa 994 \note Only one sl_NetAppPing can be handled at a time. 995 Calling this API while the same command is called from another thread, may result 996 in one of the two scenarios: 997 1. The command will wait (internal) until the previous command finish, and then be executed. 998 2. There are not enough resources and SL_POOL_IS_EMPTY error will return. 999 In this case, MAX_CONCURRENT_ACTIONS can be increased (result in memory increase) or try 1000 again later to issue the command. 1001 \warning 1002 \par Example: 1003 1004 - Sending 20 ping requests and reporting results to a callback routine when 1005 all requests are sent: 1006 \code 1007 // callback routine 1008 void pingRes(SlNetAppPingReport_t* pReport) 1009 { 1010 // handle ping results 1011 } 1012 1013 // ping activation 1014 void PingTest() 1015 { 1016 SlNetAppPingReport_t report; 1017 SlNetAppPingCommand_t pingCommand; 1018 1019 pingCommand.Ip = SL_IPV4_VAL(10,1,1,200); // destination IP address is 10.1.1.200 1020 pingCommand.PingSize = 150; // size of ping, in bytes 1021 pingCommand.PingIntervalTime = 100; // delay between pings, in milliseconds 1022 pingCommand.PingRequestTimeout = 1000; // timeout for every ping in milliseconds 1023 pingCommand.TotalNumberOfAttempts = 20; // max number of ping requests. 0 - forever 1024 pingCommand.Flags = 0; // report only when finished 1025 1026 sl_NetAppPing( &pingCommand, SL_AF_INET, &report, pingRes ); 1027 } 1028 \endcode 1029 <br> 1030 1031 - Stopping Ping command: 1032 \code 1033 Status = sl_NetAppPing(0, 0, 0, 0 ); 1034 \endcode 1035 */ 1036 #if _SL_INCLUDE_FUNC(sl_NetAppPing) 1037 _i16 sl_NetAppPing(const SlNetAppPingCommand_t* pPingParams,const _u8 Family, SlNetAppPingReport_t *pReport, const P_SL_DEV_PING_CALLBACK pPingCallback); 1038 #endif 1039 1040 /*! 1041 \brief Setting network application configurations 1042 1043 \param[in] AppId Application id, could be one of the following: 1044 - SL_NETAPP_HTTP_SERVER_ID 1045 - SL_NETAPP_DHCP_SERVER_ID (AP Role only) 1046 - SL_NETAPP_MDNS_ID 1047 - SL_NETAPP_DNS_SERVER_ID 1048 - SL_NETAPP_DEVICE_ID 1049 - SL_NETAPP_DNS_CLIENT_ID 1050 1051 \param[in] Option Set option, could be one of the following: 1052 - For SL_NETAPP_HTTP_SERVER_ID 1053 - SL_NETAPP_HTTP_PRIMARY_PORT_NUMBER 1054 - SL_NETAPP_HTTP_AUTH_CHECK 1055 - SL_NETAPP_HTTP_AUTH_NAME 1056 - SL_NETAPP_HTTP_AUTH_PASSWORD 1057 - SL_NETAPP_HTTP_AUTH_REALM 1058 - SL_NETAPP_HTTP_ROM_PAGES_ACCESS 1059 - SL_NETAPP_HTTP_SECONDARY_PORT_NUMBER 1060 - SL_NETAPP_HTTP_SECONDARY_PORT_ENABLE 1061 - SL_NETAPP_HTTP_PRIMARY_PORT_SECURITY_MODE 1062 - SL_NETAPP_HTTP_PRIVATE_KEY_FILENAME 1063 - SL_NETAPP_HTTP_DEVICE_CERTIFICATE_FILENAME 1064 - SL_NETAPP_HTTP_CA_CERTIFICATE_FILE_NAME 1065 - SL_NETAPP_HTTP_TEMP_REGISTER_MDNS_SERVICE_NAME 1066 - SL_NETAPP_HTTP_TEMP_UNREGISTER_MDNS_SERVICE_NAME 1067 - SL_NETAPP_HTTP_TIMEOUT 1068 - For SL_NETAPP_DHCP_SERVER_ID: 1069 - SL_NETAPP_DHCP_SRV_BASIC_OPT 1070 - For SL_NETAPP_MDNS_ID: 1071 - SL_NETAPP_MDNS_CONT_QUERY_OPT 1072 - SL_NETAPP_MDNS_QEVETN_MASK_OPT 1073 - SL_NETAPP_MDNS_TIMING_PARAMS_OPT 1074 - For SL_NETAPP_DEVICE_ID: 1075 - SL_NETAPP_DEVICE_URN 1076 - SL_NETAPP_DEVICE_DOMAIN 1077 - SL_NETAPP_DEVICE_NAME 1078 - For SL_NETAPP_DNS_CLIENT_ID: 1079 - SL_NETAPP_DNS_CLIENT_TIME 1080 - SL_NETAPP_DNS_CLIENT_CACHE_ENABLE 1081 - SL_NETAPP_DNS_CLIENT_CACHE_CLEAR 1082 \param[in] OptionLen Option structure length 1083 1084 \param[in] pOptionValue Pointer to the option structure 1085 1086 \par Persistent 1087 \par 1088 <b>Reset</b>: 1089 - SL_NETAPP_DEVICE_DOMAIN 1090 - SL_NETAPP_DHCP_SRV_BASIC_OPT \n 1091 \par 1092 <b>Non- Persistent</b>: 1093 - SL_NETAPP_HTTP_TIMEOUT 1094 - SL_NETAPP_HTTP_TEMP_REGISTER_MDNS_SERVICE_NAME 1095 - SL_NETAPP_HTTP_TEMP_UNREGISTER_MDNS_SERVICE_NAME \n 1096 \par 1097 <b>System Persistent</b>: 1098 - SL_NETAPP_HTTP_PRIMARY_PORT_NUMBER 1099 - SL_NETAPP_HTTP_AUTH_CHECK 1100 - SL_NETAPP_HTTP_AUTH_NAME 1101 - SL_NETAPP_HTTP_AUTH_PASSWORD 1102 - SL_NETAPP_HTTP_AUTH_REALM 1103 - SL_NETAPP_HTTP_ROM_PAGES_ACCESS 1104 - SL_NETAPP_HTTP_SECONDARY_PORT_NUMBER 1105 - SL_NETAPP_HTTP_SECONDARY_PORT_ENABLE 1106 - SL_NETAPP_HTTP_PRIMARY_PORT_SECURITY_MODE 1107 - SL_NETAPP_HTTP_PRIVATE_KEY_FILENAME 1108 - SL_NETAPP_HTTP_DEVICE_CERTIFICATE_FILENAME 1109 - SL_NETAPP_HTTP_CA_CERTIFICATE_FILE_NAME 1110 - SL_NETAPP_MDNS_CONT_QUERY_OPT 1111 - SL_NETAPP_MDNS_QEVETN_MASK_OPT 1112 - SL_NETAPP_MDNS_TIMING_PARAMS_OPT 1113 - SL_NETAPP_DEVICE_URN 1114 - SL_NETAPP_DEVICE_ID 1115 - SL_NETAPP_DNS_CLIENT_ID 1116 1117 \return Zero on success, or negative value if an error occurred. 1118 \sa sl_NetAppGet 1119 \note 1120 \warning 1121 \par Example 1122 1123 - Setting DHCP Server (AP mode) parameters example: 1124 \code 1125 SlNetAppDhcpServerBasicOpt_t dhcpParams; 1126 _u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t); 1127 dhcpParams.lease_time = 4096; // lease time (in seconds) of the IP Address 1128 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) 1129 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) 1130 sl_NetAppStop(SL_NETAPP_DHCP_SERVER_ID); // Stop DHCP server before settings 1131 sl_NetAppSet(SL_NETAPP_DHCP_SERVER_ID, SL_NETAPP_DHCP_SRV_BASIC_OPT, outLen, (_u8* )&dhcpParams); // set parameters 1132 sl_NetAppStart(SL_NETAPP_DHCP_SERVER_ID); // Start DHCP server with new settings 1133 \endcode 1134 <br> 1135 1136 - Setting Device URN name: <br> 1137 Device name, maximum length of 32 characters 1138 Device name affects URN name, and WPS file "device name" in WPS I.E (STA-WPS / P2P) 1139 In case no device URN name set, the default name is "mysimplelink" 1140 In case of setting the device name with length 0, device will return to default name "mysimplelink" 1141 Allowed characters in device name are: 'a - z' , 'A - Z' , '0-9' and '-' 1142 \code 1143 _u8 *my_device = "MY-SIMPLELINK-DEV"; 1144 sl_NetAppSet (SL_NETAPP_DEVICE_ID, SL_NETAPP_DEVICE_URN, strlen(my_device), (_u8 *) my_device); 1145 \endcode 1146 <br> 1147 1148 - Register new temporary HTTP service name for MDNS (not persistent): 1149 \code 1150 _u8 *my_http_temp_name = "New - Bonjour Service Name"; 1151 sl_NetAppSet (SL_NETAPP_HTTP_SERVER_ID, SL_NETAPP_HTTP_TEMP_REGISTER_MDNS_SERVICE_NAME, strlen(my_http_temp_name), (_u8 *) my_http_temp_name); 1152 \endcode 1153 <br> 1154 1155 - Remove registration of current HTTP internal MDNS service (not persistent) : 1156 \code 1157 _u8 *old_http_name = "0800285A7891@mysimplelink-022"; 1158 sl_NetAppSet (SL_NETAPP_HTTP_SERVER_ID, SL_NETAPP_HTTP_TEMP_UNREGISTER_MDNS_SERVICE_NAME, strlen(old_http_name), (_u8 *) old_http_name); 1159 \endcode 1160 <br> 1161 1162 - Set DNS client time example: <br> 1163 Set DNS client (sl_NetAppDnsGetHostByName) timeout, two parameters max_response_time and number_retries. 1164 number_retries: Max number of DNS request before sl_NetAppDnsGetHostByName failed, (up to 100 retries). 1165 max_response_time: DNS request timeout changed every retry, it`s start with 100 millisecond and increased every retry up to max_response_time milliseconds, (up to 2 seconds) 1166 \code 1167 SlNetAppDnsClientTime_t time; 1168 time.MaxResponseTime = 2000; 1169 time.NumOfRetries = 30; 1170 sl_NetAppSet (SL_NETAPP_DNS_CLIENT_ID, SL_NETAPP_DNS_CLIENT_TIME, sizeof(time), (_u8 *)&time); 1171 1172 \endcode 1173 <br> 1174 1175 - Clear the DNS caching: <br> 1176 \code 1177 sl_NetAppSet (SL_NETAPP_DNS_CLIENT_ID, SL_NETAPP_DNS_CLIENT_CACHE_CLEAR, 0, 0); 1178 \endcode 1179 <br> 1180 1181 - Enable / Disable the DNS caching: <br> 1182 By deafult the DNS caching is enabled, set 0 to disable the DNS caching. 1183 \code 1184 _u8 enabled = 1; 1185 sl_NetAppSet (SL_NETAPP_DNS_CLIENT_ID, SL_NETAPP_DNS_CLIENT_CACHE_ENABLE,sizeof(enabled),&enabled); 1186 \endcode 1187 <br> 1188 1189 - Start MDNS continuous querys: <br> 1190 In a continuous mDNS query mode, the device keeps sending queries to the network according to a specific service name. 1191 The query will be sent in IPv4 and IPv6 (if enabled) format. To see the completed list of responding services sl_NetAppGetServiceList() need to be called 1192 \code 1193 const signed char AddService[40] = "Printer._ipp._tcp.local"; 1194 _i16 Status; 1195 1196 Status = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_CONT_QUERY_OPT,strlen(AddService) , &AddService); 1197 \endcode 1198 <br> 1199 1200 - Stop MDNS: 1201 \code 1202 Status = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_CONT_QUERY_OPT,0 , 0); 1203 \endcode 1204 <br> 1205 1206 - Set MDNS timing parameters for service advertisement: <br> 1207 This option allows to control and reconfigures the timing parameters for service advertisement 1208 \code 1209 SlNetAppServiceAdvertiseTimingParameters_t Timing; 1210 _i16 Status; 1211 1212 Timing.t = 200; // 2 seconds 1213 Timing.p = 2; // 2 repetitions 1214 Timing.k = 2; // Telescopic factor 2 1215 Timing.RetransInterval = 0; 1216 Timing.Maxinterval = 0xFFFFFFFF; 1217 Timing.max_time = 5; 1218 1219 Status = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_TIMING_PARAMS_OPT,sizeof(Timing),&Timing); 1220 1221 \endcode 1222 <br> 1223 1224 - User-defined service types to monitor: <br> 1225 In cases that the user decides not to get responses from certain 1226 types of services it should set the adapt bit in the event mask that is related to: 1227 \code 1228 // bit 0: _ipp 1229 // bit 1: _device-info 1230 // bit 2: _http 1231 // bit 3: _https 1232 // bit 4: _workstation 1233 // bit 5: _guid 1234 // bit 6: _h323 1235 // bit 7: _ntp 1236 // bit 8: _objective 1237 // bit 9: _rdp 1238 // bit 10: _remote 1239 // bit 11: _rtsp 1240 // bit 12: _sip 1241 // bit 13: _smb 1242 // bit 14: _soap 1243 // bit 15: _ssh 1244 // bit 16: _telnet 1245 // bit 17: _tftp 1246 // bit 18: _xmpp-client 1247 // bit 19: _raop 1248 1249 _u32 EventMask; 1250 _i16 Status; 1251 1252 EventMask = BIT0 | BIT1 | BIT18; 1253 Status = sl_NetAppSet(SL_NETAPP_MDNS_ID, SL_NETAPP_MDNS_QEVETN_MASK_OPT,sizeof(EventMask),&EventMask); 1254 \endcode 1255 <br> 1256 */ 1257 #if _SL_INCLUDE_FUNC(sl_NetAppSet) 1258 _i16 sl_NetAppSet(const _u8 AppId ,const _u8 Option,const _u8 OptionLen,const _u8 *pOptionValue); 1259 #endif 1260 1261 /*! 1262 \brief Getting network applications configurations 1263 1264 \param[in] AppId Application id, could be one of the following: \n 1265 - SL_NETAPP_HTTP_SERVER_ID 1266 - SL_NETAPP_DHCP_SERVER_ID 1267 - SL_NETAPP_DNS_SERVER_ID 1268 - SL_NETAPP_DEVICE_ID 1269 - SL_NETAPP_DNS_CLIENT_ID 1270 1271 \param[in] Option Get option, could be one of the following: \n 1272 - SL_NETAPP_DHCP_SERVER_ID: 1273 - SL_NETAPP_DHCP_SRV_BASIC_OPT 1274 - SL_NETAPP_HTTP_SERVER_ID: 1275 - SL_NETAPP_HTTP_PRIMARY_PORT_NUMBER 1276 - SL_NETAPP_HTTP_AUTH_CHECK 1277 - SL_NETAPP_HTTP_AUTH_NAME 1278 - SL_NETAPP_HTTP_AUTH_PASSWORD 1279 - SL_NETAPP_HTTP_AUTH_REALM 1280 - SL_NETAPP_HTTP_ROM_PAGES_ACCESS 1281 - SL_NETAPP_HTTP_SECONDARY_PORT_NUMBER 1282 - SL_NETAPP_HTTP_SECONDARY_PORT_ENABLE 1283 - SL_NETAPP_HTTP_PRIMARY_PORT_SECURITY_MODE 1284 - SL_NETAPP_MDNS_ID: 1285 - SL_NETAPP_MDNS_CONT_QUERY_OPT 1286 - SL_NETAPP_MDNS_QEVETN_MASK_OPT 1287 - SL_NETAPP_MDNS_TIMING_PARAMS_OPT 1288 - SL_NETAPP_DEVICE_ID: 1289 - SL_NETAPP_DEVICE_URN 1290 - SL_NETAPP_DEVICE_DOMAIN 1291 - SL_NETAPP_DNS_CLIENT_ID: 1292 - SL_NETAPP_DNS_CLIENT_TIME 1293 1294 \param[in] pOptionLen The length of the allocated memory as input, when the 1295 function complete, the value of this parameter would be 1296 the len that actually read from the device.\n 1297 If the device return length that is longer from the input 1298 value, the function will cut the end of the returned structure 1299 and will return ESMALLBUF 1300 1301 \param[out] pOptionValue pointer to the option structure which will be filled with the response from the device 1302 1303 \return Zero on success, or negative value if an error occurred. 1304 1305 \sa sl_NetAppSet 1306 \note 1307 \warning 1308 \par Example 1309 1310 - Getting DHCP Server parameters example: 1311 \code 1312 SlNetAppDhcpServerBasicOpt_t dhcpParams; 1313 _u8 outLen = sizeof(SlNetAppDhcpServerBasicOpt_t); 1314 sl_NetAppGet(SL_NETAPP_DHCP_SERVER_ID, SL_NETAPP_SET_DHCP_SRV_BASIC_OPT, &outLen, (_u8* )&dhcpParams); 1315 1316 printf("DHCP Start IP %d.%d.%d.%d End IP %d.%d.%d.%d Lease time seconds %d\n", 1317 SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,2), 1318 SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_start,0), 1319 SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,3),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,2), 1320 SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,1),SL_IPV4_BYTE(dhcpParams.ipv4_addr_last,0), 1321 dhcpParams.lease_time); 1322 \endcode 1323 <br> 1324 1325 - Getting device URN name: <br> 1326 Maximum length of 32 characters of device name. 1327 Device name affects URN name, own SSID name in AP mode, and WPS file "device name" in WPS I.E (STA-WPS / P2P) 1328 in case no device URN name set, the default name is "mysimplelink" 1329 \code 1330 _u8 my_device_name[SL_NETAPP_MAX_DEVICE_URN_LEN]; 1331 sl_NetAppGet (SL_NETAPP_DEVICE_ID, SL_NETAPP_DEVICE_URN, strlen(my_device_name), (_u8 *)my_device_name); 1332 \endcode 1333 <br> 1334 1335 - Getting DNS client time: <br> 1336 Get DNS client (sl_NetAppDnsGetHostByName) timeout, two parameters max_response_time and number_retries. 1337 number_retries: Max number of DNS request before sl_NetAppDnsGetHostByName failed. 1338 max_response_time: DNS request timeout changed every retry, it`s start with 100 millisecond and increased every retry up to max_response_time milliseconds 1339 \code 1340 SlNetAppDnsClientTime_t time; 1341 _u8 pOptionLen = sizeof(time); 1342 sl_NetAppGet (SL_NETAPP_DNS_CLIENT_ID, SL_NETAPP_DNS_CLIENT_TIME, &pOptionLen, (_u8 *)&time); 1343 \endcode 1344 <br> 1345 1346 - get DNS caching mode: <br> 1347 By deafult the DNS caching is enabled, 0 - disable, 1 - enabled. 1348 \code 1349 _u8 enabled; 1350 _u8 pOptionLen = sizeof(enabled) 1351 sl_NetAppGet (SL_NETAPP_DNS_CLIENT_ID, SL_NETAPP_DNS_CLIENT_CACHE_ENABLE, &pOptionLen,&enabled); 1352 \endcode 1353 <br> 1354 1355 - Getting active applications: <br> 1356 Get active applications for active role. return value is mask of the active application (similar defines as sl_NetAppStart\sl_NetAppStop): 1357 \code 1358 _u32 AppBitMap; 1359 _u8 pOptionLen = sizeof(AppBitMap); 1360 sl_NetAppGet (SL_NETAPP_STATUS, SL_NETAPP_STATUS_ACTIVE_APP, &pOptionLen, (_u8 *)&AppBitMap); 1361 1362 \endcode 1363 1364 */ 1365 #if _SL_INCLUDE_FUNC(sl_NetAppGet) 1366 _i16 sl_NetAppGet(const _u8 AppId, const _u8 Option,_u8 *pOptionLen, _u8 *pOptionValue); 1367 #endif 1368 1369 /*! 1370 \brief Function for sending Netapp response or data following a Netapp request event (i.e. HTTP GET request) 1371 1372 1373 \param[in] Handle Handle to send the data to. Should match the handle received in the Netapp request event 1374 \param[in] DataLen Data Length 1375 \param[in] pData Data to send. Can be just data payload or metadata (depends on flags) 1376 \param[out] Flags Can have the following values: 1377 - SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION - More data will arrive in subsequent calls to NetAppSend 1378 - SL_NETAPP_REQUEST_RESPONSE_FLAGS_METADATA - 0 - data is payload, 1 - data is metadata 1379 - SL_NETAPP_REQUEST_RESPONSE_FLAGS_ACCUMULATION - The network processor should accumulate the data chunks and will process it when it is completelly received 1380 1381 \return Zero on success, or negative error code on failure 1382 1383 \sa sl_NetAppRecv 1384 \note 1385 \warning 1386 */ 1387 #if _SL_INCLUDE_FUNC(sl_NetAppSend) 1388 _u16 sl_NetAppSend( _u16 Handle, _u16 DataLen, _u8 *pData, _u32 Flags); 1389 #endif 1390 1391 /*! 1392 \brief Function for retrieving data from the network processor following a Netapp request event (i.e. HTTP POST request) 1393 1394 \param[in] Handle Handle to receive data from. Should match the handle received in the Netapp request event 1395 \param[in,out] *DataLen Max buffer size (in) / Actual data received (out) 1396 \param[out] *pData Data received 1397 \param[in,out] *Flags Can have the following values: 1398 - SL_NETAPP_REQUEST_RESPONSE_FLAGS_CONTINUATION (out) 1399 - More data is pending in the network processor. Application should continue reading the data by calling sl_NetAppRecv again 1400 1401 \return Zero on success, or negative error code on failure 1402 1403 \sa sl_NetAppSend 1404 \note 1405 \warning handle is received in the sl_NetAppRequestHandler callback. Handle is valid until all data is receive from the network processor. 1406 */ 1407 #if _SL_INCLUDE_FUNC(sl_NetAppRecv) 1408 _SlReturnVal_t sl_NetAppRecv( _u16 Handle, _u16 *DataLen, _u8 *pData, _u32 *Flags); 1409 #endif 1410 1411 /*! 1412 1413 Close the Doxygen group. 1414 @} 1415 1416 */ 1417 1418 1419 #ifdef __cplusplus 1420 } 1421 #endif /* __cplusplus */ 1422 1423 #endif /* __NETAPP_H__ */ 1424 1425