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

Dependencies:   MaximInterface

The MAXREFDES155# is an internet-of-things (IoT) embedded-security reference design, built to authenticate and control a sensing node using elliptic-curve-based public-key cryptography with control and notification from a web server.

The hardware includes an ARM® mbed™ shield and attached sensor endpoint. The shield contains a DS2476 DeepCover® ECDSA/SHA-2 coprocessor, Wifi communication, LCD push-button controls, and status LEDs. The sensor endpoint is attached to the shield using a 300mm cable and contains a DS28C36 DeepCover ECDSA/SHA-2 authenticator, IR-thermal sensor, and aiming laser for the IR sensor. The MAXREFDES155# is equipped with a standard Arduino® form-factor shield connector for immediate testing using an mbed board such as the MAX32600MBED#. The combination of these two devices represent an IoT device. Communication to the web server is accomplished with the shield Wifi circuitry. Communication from the shield to the attached sensor module is accomplished over I2C . The sensor module represents an IoT endpoint that generates small data with a requirement for message authenticity/integrity and secure on/off operational control.

The design is hierarchical with each mbed platform and shield communicating data from the sensor node to a web server that maintains a centralized log and dispatches notifications as necessary. The simplicity of this design enables rapid integration into any star-topology IoT network to provide security with the low overhead and cost provided by the ECDSA-P256 asymmetric-key and SHA-256 symmetric-key algorithms.

More information about the MAXREFDES155# is available on the Maxim Integrated website.

Committer:
IanBenzMaxim
Date:
Tue Dec 03 12:56:25 2019 -0600
Revision:
18:c2631e985780
Parent:
16:a004191a79ab
Updated MaximInterface to version 2.1.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
IanBenzMaxim 0:33d4e66780c0 1 /*
IanBenzMaxim 0:33d4e66780c0 2 * netapp.c - CC31xx/CC32xx Host Driver Implementation
IanBenzMaxim 0:33d4e66780c0 3 *
IanBenzMaxim 0:33d4e66780c0 4 * Copyright (C) 2015 Texas Instruments Incorporated - http://www.ti.com/
IanBenzMaxim 0:33d4e66780c0 5 *
IanBenzMaxim 0:33d4e66780c0 6 *
IanBenzMaxim 0:33d4e66780c0 7 * Redistribution and use in source and binary forms, with or without
IanBenzMaxim 0:33d4e66780c0 8 * modification, are permitted provided that the following conditions
IanBenzMaxim 0:33d4e66780c0 9 * are met:
IanBenzMaxim 0:33d4e66780c0 10 *
IanBenzMaxim 0:33d4e66780c0 11 * Redistributions of source code must retain the above copyright
IanBenzMaxim 0:33d4e66780c0 12 * notice, this list of conditions and the following disclaimer.
IanBenzMaxim 0:33d4e66780c0 13 *
IanBenzMaxim 0:33d4e66780c0 14 * Redistributions in binary form must reproduce the above copyright
IanBenzMaxim 0:33d4e66780c0 15 * notice, this list of conditions and the following disclaimer in the
IanBenzMaxim 0:33d4e66780c0 16 * documentation and/or other materials provided with the
IanBenzMaxim 0:33d4e66780c0 17 * distribution.
IanBenzMaxim 0:33d4e66780c0 18 *
IanBenzMaxim 0:33d4e66780c0 19 * Neither the name of Texas Instruments Incorporated nor the names of
IanBenzMaxim 0:33d4e66780c0 20 * its contributors may be used to endorse or promote products derived
IanBenzMaxim 0:33d4e66780c0 21 * from this software without specific prior written permission.
IanBenzMaxim 0:33d4e66780c0 22 *
IanBenzMaxim 0:33d4e66780c0 23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
IanBenzMaxim 0:33d4e66780c0 24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
IanBenzMaxim 0:33d4e66780c0 25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
IanBenzMaxim 0:33d4e66780c0 26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
IanBenzMaxim 0:33d4e66780c0 27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
IanBenzMaxim 0:33d4e66780c0 28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
IanBenzMaxim 0:33d4e66780c0 29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
IanBenzMaxim 0:33d4e66780c0 30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
IanBenzMaxim 0:33d4e66780c0 31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
IanBenzMaxim 0:33d4e66780c0 32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
IanBenzMaxim 0:33d4e66780c0 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
IanBenzMaxim 0:33d4e66780c0 34 *
IanBenzMaxim 0:33d4e66780c0 35 */
IanBenzMaxim 0:33d4e66780c0 36
IanBenzMaxim 0:33d4e66780c0 37
IanBenzMaxim 0:33d4e66780c0 38
IanBenzMaxim 0:33d4e66780c0 39 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 40 /* Include files */
IanBenzMaxim 0:33d4e66780c0 41 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 42 #include "simplelink.h"
IanBenzMaxim 0:33d4e66780c0 43 #include "protocol.h"
IanBenzMaxim 0:33d4e66780c0 44 #include "driver.h"
IanBenzMaxim 0:33d4e66780c0 45
IanBenzMaxim 0:33d4e66780c0 46 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 47 /* Macro declarations */
IanBenzMaxim 0:33d4e66780c0 48 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 49 #define NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT ((_u32)0x1 << 31)
IanBenzMaxim 0:33d4e66780c0 50
IanBenzMaxim 0:33d4e66780c0 51 #ifdef SL_TINY
IanBenzMaxim 0:33d4e66780c0 52 #define NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH 63
IanBenzMaxim 0:33d4e66780c0 53 #else
IanBenzMaxim 0:33d4e66780c0 54 #define NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH 255
IanBenzMaxim 0:33d4e66780c0 55 #endif
IanBenzMaxim 0:33d4e66780c0 56
IanBenzMaxim 0:33d4e66780c0 57
IanBenzMaxim 0:33d4e66780c0 58 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 59 /* Functions prototypes */
IanBenzMaxim 0:33d4e66780c0 60 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 61 _SlReturnVal_t _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf);
IanBenzMaxim 0:33d4e66780c0 62
IanBenzMaxim 0:33d4e66780c0 63 #ifndef SL_TINY_EXT
IanBenzMaxim 0:33d4e66780c0 64 _SlReturnVal_t _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf);
IanBenzMaxim 0:33d4e66780c0 65 _SlReturnVal_t _sl_HandleAsync_PingResponse(void *pVoidBuf);
IanBenzMaxim 0:33d4e66780c0 66 #endif
IanBenzMaxim 0:33d4e66780c0 67
IanBenzMaxim 0:33d4e66780c0 68 static void CopyPingResultsToReport(_PingReportResponse_t *pResults,SlPingReport_t *pReport);
IanBenzMaxim 0:33d4e66780c0 69 _i16 sl_NetAppMDNSRegisterUnregisterService(const _i8* pServiceName,
IanBenzMaxim 0:33d4e66780c0 70 const _u8 ServiceNameLen,
IanBenzMaxim 0:33d4e66780c0 71 const _i8* pText,
IanBenzMaxim 0:33d4e66780c0 72 const _u8 TextLen,
IanBenzMaxim 0:33d4e66780c0 73 const _u16 Port,
IanBenzMaxim 0:33d4e66780c0 74 const _u32 TTL,
IanBenzMaxim 0:33d4e66780c0 75 const _u32 Options);
IanBenzMaxim 0:33d4e66780c0 76
IanBenzMaxim 0:33d4e66780c0 77 #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
IanBenzMaxim 0:33d4e66780c0 78 _u16 _sl_NetAppSendTokenValue(slHttpServerData_t * Token);
IanBenzMaxim 0:33d4e66780c0 79 #endif
IanBenzMaxim 0:33d4e66780c0 80 typedef union
IanBenzMaxim 0:33d4e66780c0 81 {
IanBenzMaxim 0:33d4e66780c0 82 _NetAppStartStopCommand_t Cmd;
IanBenzMaxim 0:33d4e66780c0 83 _NetAppStartStopResponse_t Rsp;
IanBenzMaxim 0:33d4e66780c0 84 }_SlNetAppStartStopMsg_u;
IanBenzMaxim 0:33d4e66780c0 85
IanBenzMaxim 0:33d4e66780c0 86
IanBenzMaxim 0:33d4e66780c0 87 #if _SL_INCLUDE_FUNC(sl_NetAppStart)
IanBenzMaxim 0:33d4e66780c0 88
IanBenzMaxim 0:33d4e66780c0 89 static const _SlCmdCtrl_t _SlNetAppStartCtrl =
IanBenzMaxim 0:33d4e66780c0 90
IanBenzMaxim 0:33d4e66780c0 91 {
IanBenzMaxim 0:33d4e66780c0 92 SL_OPCODE_NETAPP_START_COMMAND,
IanBenzMaxim 0:33d4e66780c0 93 (_SlArgSize_t)sizeof(_NetAppStartStopCommand_t),
IanBenzMaxim 0:33d4e66780c0 94 (_SlArgSize_t)sizeof(_NetAppStartStopResponse_t)
IanBenzMaxim 0:33d4e66780c0 95 };
IanBenzMaxim 0:33d4e66780c0 96
IanBenzMaxim 0:33d4e66780c0 97 _i16 sl_NetAppStart(const _u32 AppBitMap)
IanBenzMaxim 0:33d4e66780c0 98 {
IanBenzMaxim 0:33d4e66780c0 99 _SlNetAppStartStopMsg_u Msg;
IanBenzMaxim 0:33d4e66780c0 100 Msg.Cmd.appId = AppBitMap;
IanBenzMaxim 0:33d4e66780c0 101
IanBenzMaxim 0:33d4e66780c0 102 /* verify no erorr handling in progress. if in progress than
IanBenzMaxim 0:33d4e66780c0 103 ignore the API execution and return immediately with an error */
IanBenzMaxim 0:33d4e66780c0 104 VERIFY_NO_ERROR_HANDLING_IN_PROGRESS();
IanBenzMaxim 0:33d4e66780c0 105 VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppStartCtrl, &Msg, NULL));
IanBenzMaxim 0:33d4e66780c0 106
IanBenzMaxim 0:33d4e66780c0 107 return Msg.Rsp.status;
IanBenzMaxim 0:33d4e66780c0 108 }
IanBenzMaxim 0:33d4e66780c0 109 #endif
IanBenzMaxim 0:33d4e66780c0 110
IanBenzMaxim 0:33d4e66780c0 111 /*****************************************************************************
IanBenzMaxim 0:33d4e66780c0 112 sl_NetAppStop
IanBenzMaxim 0:33d4e66780c0 113 *****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 114 #if _SL_INCLUDE_FUNC(sl_NetAppStop)
IanBenzMaxim 0:33d4e66780c0 115
IanBenzMaxim 0:33d4e66780c0 116
IanBenzMaxim 0:33d4e66780c0 117 static const _SlCmdCtrl_t _SlNetAppStopCtrl =
IanBenzMaxim 0:33d4e66780c0 118 {
IanBenzMaxim 0:33d4e66780c0 119 SL_OPCODE_NETAPP_STOP_COMMAND,
IanBenzMaxim 0:33d4e66780c0 120 (_SlArgSize_t)sizeof(_NetAppStartStopCommand_t),
IanBenzMaxim 0:33d4e66780c0 121 (_SlArgSize_t)sizeof(_NetAppStartStopResponse_t)
IanBenzMaxim 0:33d4e66780c0 122 };
IanBenzMaxim 0:33d4e66780c0 123
IanBenzMaxim 0:33d4e66780c0 124
IanBenzMaxim 0:33d4e66780c0 125
IanBenzMaxim 0:33d4e66780c0 126 _i16 sl_NetAppStop(const _u32 AppBitMap)
IanBenzMaxim 0:33d4e66780c0 127 {
IanBenzMaxim 0:33d4e66780c0 128 _SlNetAppStartStopMsg_u Msg;
IanBenzMaxim 0:33d4e66780c0 129
IanBenzMaxim 0:33d4e66780c0 130 /* verify no erorr handling in progress. if in progress than
IanBenzMaxim 0:33d4e66780c0 131 ignore the API execution and return immediately with an error */
IanBenzMaxim 0:33d4e66780c0 132 VERIFY_NO_ERROR_HANDLING_IN_PROGRESS();
IanBenzMaxim 0:33d4e66780c0 133 Msg.Cmd.appId = AppBitMap;
IanBenzMaxim 0:33d4e66780c0 134 VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppStopCtrl, &Msg, NULL));
IanBenzMaxim 0:33d4e66780c0 135
IanBenzMaxim 0:33d4e66780c0 136 return Msg.Rsp.status;
IanBenzMaxim 0:33d4e66780c0 137 }
IanBenzMaxim 0:33d4e66780c0 138 #endif
IanBenzMaxim 0:33d4e66780c0 139
IanBenzMaxim 0:33d4e66780c0 140
IanBenzMaxim 0:33d4e66780c0 141 /******************************************************************************/
IanBenzMaxim 0:33d4e66780c0 142 /* sl_NetAppGetServiceList */
IanBenzMaxim 0:33d4e66780c0 143 /******************************************************************************/
IanBenzMaxim 0:33d4e66780c0 144 typedef struct
IanBenzMaxim 0:33d4e66780c0 145 {
IanBenzMaxim 0:33d4e66780c0 146 _u8 IndexOffest;
IanBenzMaxim 0:33d4e66780c0 147 _u8 MaxServiceCount;
IanBenzMaxim 0:33d4e66780c0 148 _u8 Flags;
IanBenzMaxim 0:33d4e66780c0 149 _i8 Padding;
IanBenzMaxim 0:33d4e66780c0 150 }NetappGetServiceListCMD_t;
IanBenzMaxim 0:33d4e66780c0 151
IanBenzMaxim 0:33d4e66780c0 152 typedef union
IanBenzMaxim 0:33d4e66780c0 153 {
IanBenzMaxim 0:33d4e66780c0 154 NetappGetServiceListCMD_t Cmd;
IanBenzMaxim 0:33d4e66780c0 155 _BasicResponse_t Rsp;
IanBenzMaxim 0:33d4e66780c0 156 }_SlNetappGetServiceListMsg_u;
IanBenzMaxim 0:33d4e66780c0 157
IanBenzMaxim 0:33d4e66780c0 158
IanBenzMaxim 0:33d4e66780c0 159 #if _SL_INCLUDE_FUNC(sl_NetAppGetServiceList)
IanBenzMaxim 0:33d4e66780c0 160
IanBenzMaxim 0:33d4e66780c0 161 static const _SlCmdCtrl_t _SlGetServiceListeCtrl =
IanBenzMaxim 0:33d4e66780c0 162 {
IanBenzMaxim 0:33d4e66780c0 163 SL_OPCODE_NETAPP_NETAPP_MDNS_LOOKUP_SERVICE,
IanBenzMaxim 0:33d4e66780c0 164 (_SlArgSize_t)sizeof(NetappGetServiceListCMD_t),
IanBenzMaxim 0:33d4e66780c0 165 (_SlArgSize_t)sizeof(_BasicResponse_t)
IanBenzMaxim 0:33d4e66780c0 166 };
IanBenzMaxim 0:33d4e66780c0 167
IanBenzMaxim 0:33d4e66780c0 168 _i16 sl_NetAppGetServiceList(const _u8 IndexOffest,
IanBenzMaxim 0:33d4e66780c0 169 const _u8 MaxServiceCount,
IanBenzMaxim 0:33d4e66780c0 170 const _u8 Flags,
IanBenzMaxim 0:33d4e66780c0 171 _i8 *pBuffer,
IanBenzMaxim 0:33d4e66780c0 172 const _u32 RxBufferLength
IanBenzMaxim 0:33d4e66780c0 173 )
IanBenzMaxim 0:33d4e66780c0 174 {
IanBenzMaxim 0:33d4e66780c0 175
IanBenzMaxim 0:33d4e66780c0 176 _i32 retVal= 0;
IanBenzMaxim 0:33d4e66780c0 177 _SlNetappGetServiceListMsg_u Msg;
IanBenzMaxim 0:33d4e66780c0 178 _SlCmdExt_t CmdExt;
IanBenzMaxim 0:33d4e66780c0 179 _u16 ServiceSize = 0;
IanBenzMaxim 0:33d4e66780c0 180 _u16 BufferSize = 0;
IanBenzMaxim 0:33d4e66780c0 181
IanBenzMaxim 0:33d4e66780c0 182 /* verify no erorr handling in progress. if in progress than
IanBenzMaxim 0:33d4e66780c0 183 ignore the API execution and return immediately with an error */
IanBenzMaxim 0:33d4e66780c0 184 VERIFY_NO_ERROR_HANDLING_IN_PROGRESS();
IanBenzMaxim 0:33d4e66780c0 185
IanBenzMaxim 0:33d4e66780c0 186 /*
IanBenzMaxim 0:33d4e66780c0 187 Calculate RX pBuffer size
IanBenzMaxim 0:33d4e66780c0 188 WARNING:
IanBenzMaxim 0:33d4e66780c0 189 if this size is BufferSize than 1480 error should be returned because there
IanBenzMaxim 0:33d4e66780c0 190 is no place in the RX packet.
IanBenzMaxim 0:33d4e66780c0 191 */
IanBenzMaxim 0:33d4e66780c0 192 switch(Flags)
IanBenzMaxim 0:33d4e66780c0 193 {
IanBenzMaxim 0:33d4e66780c0 194 case SL_NET_APP_FULL_SERVICE_WITH_TEXT_IPV4_TYPE:
IanBenzMaxim 0:33d4e66780c0 195 ServiceSize = (_u16)sizeof(SlNetAppGetFullServiceWithTextIpv4List_t);
IanBenzMaxim 0:33d4e66780c0 196 break;
IanBenzMaxim 0:33d4e66780c0 197
IanBenzMaxim 0:33d4e66780c0 198 case SL_NET_APP_FULL_SERVICE_IPV4_TYPE:
IanBenzMaxim 0:33d4e66780c0 199 ServiceSize = (_u16)sizeof(SlNetAppGetFullServiceIpv4List_t);
IanBenzMaxim 0:33d4e66780c0 200 break;
IanBenzMaxim 0:33d4e66780c0 201
IanBenzMaxim 0:33d4e66780c0 202 case SL_NET_APP_SHORT_SERVICE_IPV4_TYPE:
IanBenzMaxim 0:33d4e66780c0 203 ServiceSize = (_u16)sizeof(SlNetAppGetShortServiceIpv4List_t);
IanBenzMaxim 0:33d4e66780c0 204 break;
IanBenzMaxim 0:33d4e66780c0 205
IanBenzMaxim 0:33d4e66780c0 206 default:
IanBenzMaxim 0:33d4e66780c0 207 ServiceSize = (_u16)sizeof(_BasicResponse_t);
IanBenzMaxim 0:33d4e66780c0 208 break;
IanBenzMaxim 0:33d4e66780c0 209 }
IanBenzMaxim 0:33d4e66780c0 210
IanBenzMaxim 0:33d4e66780c0 211
IanBenzMaxim 0:33d4e66780c0 212
IanBenzMaxim 0:33d4e66780c0 213 BufferSize = MaxServiceCount * ServiceSize;
IanBenzMaxim 0:33d4e66780c0 214
IanBenzMaxim 0:33d4e66780c0 215 /*Check the size of the requested services is smaller than size of the user buffer.
IanBenzMaxim 0:33d4e66780c0 216 If not an error is returned in order to avoid overwriting memory. */
IanBenzMaxim 0:33d4e66780c0 217 if(RxBufferLength <= BufferSize)
IanBenzMaxim 0:33d4e66780c0 218 {
IanBenzMaxim 0:33d4e66780c0 219 return SL_ERROR_NETAPP_RX_BUFFER_LENGTH_ERROR;
IanBenzMaxim 0:33d4e66780c0 220 }
IanBenzMaxim 0:33d4e66780c0 221
IanBenzMaxim 0:33d4e66780c0 222 _SlDrvResetCmdExt(&CmdExt);
IanBenzMaxim 0:33d4e66780c0 223 CmdExt.RxPayloadLen = (_i16)BufferSize;
IanBenzMaxim 0:33d4e66780c0 224 CmdExt.pRxPayload = (_u8 *)pBuffer;
IanBenzMaxim 0:33d4e66780c0 225
IanBenzMaxim 0:33d4e66780c0 226 Msg.Cmd.IndexOffest = IndexOffest;
IanBenzMaxim 0:33d4e66780c0 227 Msg.Cmd.MaxServiceCount = MaxServiceCount;
IanBenzMaxim 0:33d4e66780c0 228 Msg.Cmd.Flags = Flags;
IanBenzMaxim 0:33d4e66780c0 229 Msg.Cmd.Padding = 0;
IanBenzMaxim 0:33d4e66780c0 230
IanBenzMaxim 0:33d4e66780c0 231 VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetServiceListeCtrl, &Msg, &CmdExt));
IanBenzMaxim 0:33d4e66780c0 232 retVal = Msg.Rsp.status;
IanBenzMaxim 0:33d4e66780c0 233
IanBenzMaxim 0:33d4e66780c0 234 return (_i16)retVal;
IanBenzMaxim 0:33d4e66780c0 235 }
IanBenzMaxim 0:33d4e66780c0 236
IanBenzMaxim 0:33d4e66780c0 237 #endif
IanBenzMaxim 0:33d4e66780c0 238
IanBenzMaxim 0:33d4e66780c0 239 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 240 /* sl_mDNSRegisterService */
IanBenzMaxim 0:33d4e66780c0 241 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 242 /*
IanBenzMaxim 0:33d4e66780c0 243 * The below struct depicts the constant parameters of the command/API RegisterService.
IanBenzMaxim 0:33d4e66780c0 244 *
IanBenzMaxim 0:33d4e66780c0 245 1. ServiceLen - The length of the service should be smaller than NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
IanBenzMaxim 0:33d4e66780c0 246 2. TextLen - The length of the text should be smaller than NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
IanBenzMaxim 0:33d4e66780c0 247 3. port - The port on this target host.
IanBenzMaxim 0:33d4e66780c0 248 4. TTL - The TTL of the service
IanBenzMaxim 0:33d4e66780c0 249 5. Options - bitwise parameters:
IanBenzMaxim 0:33d4e66780c0 250 bit 0 - is unique (means if the service needs to be unique)
IanBenzMaxim 0:33d4e66780c0 251 bit 31 - for internal use if the service should be added or deleted (set means ADD).
IanBenzMaxim 0:33d4e66780c0 252 bit 1-30 for future.
IanBenzMaxim 0:33d4e66780c0 253
IanBenzMaxim 0:33d4e66780c0 254 NOTE:
IanBenzMaxim 0:33d4e66780c0 255
IanBenzMaxim 0:33d4e66780c0 256 1. There are another variable parameter is this API which is the service name and the text.
IanBenzMaxim 0:33d4e66780c0 257 2. According to now there is no warning and Async event to user on if the service is a unique.
IanBenzMaxim 0:33d4e66780c0 258 *
IanBenzMaxim 0:33d4e66780c0 259 */
IanBenzMaxim 0:33d4e66780c0 260
IanBenzMaxim 0:33d4e66780c0 261
IanBenzMaxim 0:33d4e66780c0 262 typedef struct
IanBenzMaxim 0:33d4e66780c0 263 {
IanBenzMaxim 0:33d4e66780c0 264 _u8 ServiceNameLen;
IanBenzMaxim 0:33d4e66780c0 265 _u8 TextLen;
IanBenzMaxim 0:33d4e66780c0 266 _u16 Port;
IanBenzMaxim 0:33d4e66780c0 267 _u32 TTL;
IanBenzMaxim 0:33d4e66780c0 268 _u32 Options;
IanBenzMaxim 0:33d4e66780c0 269 }NetappMdnsSetService_t;
IanBenzMaxim 0:33d4e66780c0 270
IanBenzMaxim 0:33d4e66780c0 271 typedef union
IanBenzMaxim 0:33d4e66780c0 272 {
IanBenzMaxim 0:33d4e66780c0 273 NetappMdnsSetService_t Cmd;
IanBenzMaxim 0:33d4e66780c0 274 _BasicResponse_t Rsp;
IanBenzMaxim 0:33d4e66780c0 275 }_SlNetappMdnsRegisterServiceMsg_u;
IanBenzMaxim 0:33d4e66780c0 276
IanBenzMaxim 0:33d4e66780c0 277
IanBenzMaxim 0:33d4e66780c0 278 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterUnregisterService)
IanBenzMaxim 0:33d4e66780c0 279
IanBenzMaxim 0:33d4e66780c0 280 static const _SlCmdCtrl_t _SlRegisterServiceCtrl =
IanBenzMaxim 0:33d4e66780c0 281 {
IanBenzMaxim 0:33d4e66780c0 282 SL_OPCODE_NETAPP_MDNSREGISTERSERVICE,
IanBenzMaxim 0:33d4e66780c0 283 (_SlArgSize_t)sizeof(NetappMdnsSetService_t),
IanBenzMaxim 0:33d4e66780c0 284 (_SlArgSize_t)sizeof(_BasicResponse_t)
IanBenzMaxim 0:33d4e66780c0 285 };
IanBenzMaxim 0:33d4e66780c0 286
IanBenzMaxim 0:33d4e66780c0 287 /******************************************************************************
IanBenzMaxim 0:33d4e66780c0 288
IanBenzMaxim 0:33d4e66780c0 289 sl_NetAppMDNSRegisterService
IanBenzMaxim 0:33d4e66780c0 290
IanBenzMaxim 0:33d4e66780c0 291 CALLER user from its host
IanBenzMaxim 0:33d4e66780c0 292
IanBenzMaxim 0:33d4e66780c0 293
IanBenzMaxim 0:33d4e66780c0 294 DESCRIPTION:
IanBenzMaxim 0:33d4e66780c0 295 Add/delete service
IanBenzMaxim 0:33d4e66780c0 296 The function manipulates the command that register the service and call
IanBenzMaxim 0:33d4e66780c0 297 to the NWP in order to add/delete the service to/from the mDNS package and to/from the DB.
IanBenzMaxim 0:33d4e66780c0 298
IanBenzMaxim 0:33d4e66780c0 299 This register service is a service offered by the application.
IanBenzMaxim 0:33d4e66780c0 300 This unregister service is a service offered by the application before.
IanBenzMaxim 0:33d4e66780c0 301
IanBenzMaxim 0:33d4e66780c0 302 The service name should be full service name according to RFC
IanBenzMaxim 0:33d4e66780c0 303 of the DNS-SD - means the value in name field in SRV answer.
IanBenzMaxim 0:33d4e66780c0 304
IanBenzMaxim 0:33d4e66780c0 305 Example for service name:
IanBenzMaxim 0:33d4e66780c0 306 1. PC1._ipp._tcp.local
IanBenzMaxim 0:33d4e66780c0 307 2. PC2_server._ftp._tcp.local
IanBenzMaxim 0:33d4e66780c0 308
IanBenzMaxim 0:33d4e66780c0 309 If the option is_unique is set, mDNS probes the service name to make sure
IanBenzMaxim 0:33d4e66780c0 310 it is unique before starting to announce the service on the network.
IanBenzMaxim 0:33d4e66780c0 311 Instance is the instance portion of the service name.
IanBenzMaxim 0:33d4e66780c0 312
IanBenzMaxim 0:33d4e66780c0 313
IanBenzMaxim 0:33d4e66780c0 314
IanBenzMaxim 0:33d4e66780c0 315
IanBenzMaxim 0:33d4e66780c0 316 PARAMETERS:
IanBenzMaxim 0:33d4e66780c0 317
IanBenzMaxim 0:33d4e66780c0 318 The command is from constant parameters and variables parameters.
IanBenzMaxim 0:33d4e66780c0 319
IanBenzMaxim 0:33d4e66780c0 320 Constant parameters are:
IanBenzMaxim 0:33d4e66780c0 321
IanBenzMaxim 0:33d4e66780c0 322 ServiceLen - The length of the service.
IanBenzMaxim 0:33d4e66780c0 323 TextLen - The length of the service should be smaller than 64.
IanBenzMaxim 0:33d4e66780c0 324 port - The port on this target host.
IanBenzMaxim 0:33d4e66780c0 325 TTL - The TTL of the service
IanBenzMaxim 0:33d4e66780c0 326 Options - bitwise parameters:
IanBenzMaxim 0:33d4e66780c0 327 bit 0 - is unique (means if the service needs to be unique)
IanBenzMaxim 0:33d4e66780c0 328 bit 31 - for internal use if the service should be added or deleted (set means ADD).
IanBenzMaxim 0:33d4e66780c0 329 bit 1-30 for future.
IanBenzMaxim 0:33d4e66780c0 330
IanBenzMaxim 0:33d4e66780c0 331 The variables parameters are:
IanBenzMaxim 0:33d4e66780c0 332
IanBenzMaxim 0:33d4e66780c0 333 Service name(full service name) - The service name.
IanBenzMaxim 0:33d4e66780c0 334 Example for service name:
IanBenzMaxim 0:33d4e66780c0 335 1. PC1._ipp._tcp.local
IanBenzMaxim 0:33d4e66780c0 336 2. PC2_server._ftp._tcp.local
IanBenzMaxim 0:33d4e66780c0 337
IanBenzMaxim 0:33d4e66780c0 338 Text - The description of the service.
IanBenzMaxim 0:33d4e66780c0 339 should be as mentioned in the RFC
IanBenzMaxim 0:33d4e66780c0 340 (according to type of the service IPP,FTP...)
IanBenzMaxim 0:33d4e66780c0 341
IanBenzMaxim 0:33d4e66780c0 342 NOTE - pay attention
IanBenzMaxim 0:33d4e66780c0 343
IanBenzMaxim 0:33d4e66780c0 344 1. Temporary - there is an allocation on stack of internal buffer.
IanBenzMaxim 0:33d4e66780c0 345 Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
IanBenzMaxim 0:33d4e66780c0 346 It means that the sum of the text length and service name length cannot be bigger than
IanBenzMaxim 0:33d4e66780c0 347 NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
IanBenzMaxim 0:33d4e66780c0 348 If it is - An error is returned.
IanBenzMaxim 0:33d4e66780c0 349
IanBenzMaxim 0:33d4e66780c0 350 2. According to now from certain constraints the variables parameters are set in the
IanBenzMaxim 0:33d4e66780c0 351 attribute part (contain constant parameters)
IanBenzMaxim 0:33d4e66780c0 352
IanBenzMaxim 0:33d4e66780c0 353
IanBenzMaxim 0:33d4e66780c0 354
IanBenzMaxim 0:33d4e66780c0 355 RETURNS: Status - the immediate response of the command status.
IanBenzMaxim 0:33d4e66780c0 356 0 means success.
IanBenzMaxim 0:33d4e66780c0 357
IanBenzMaxim 0:33d4e66780c0 358
IanBenzMaxim 0:33d4e66780c0 359
IanBenzMaxim 0:33d4e66780c0 360 ******************************************************************************/
IanBenzMaxim 0:33d4e66780c0 361 _i16 sl_NetAppMDNSRegisterUnregisterService( const _i8* pServiceName,
IanBenzMaxim 0:33d4e66780c0 362 const _u8 ServiceNameLen,
IanBenzMaxim 0:33d4e66780c0 363 const _i8* pText,
IanBenzMaxim 0:33d4e66780c0 364 const _u8 TextLen,
IanBenzMaxim 0:33d4e66780c0 365 const _u16 Port,
IanBenzMaxim 0:33d4e66780c0 366 const _u32 TTL,
IanBenzMaxim 0:33d4e66780c0 367 const _u32 Options)
IanBenzMaxim 0:33d4e66780c0 368
IanBenzMaxim 0:33d4e66780c0 369 {
IanBenzMaxim 0:33d4e66780c0 370 _SlNetappMdnsRegisterServiceMsg_u Msg;
IanBenzMaxim 0:33d4e66780c0 371 _SlCmdExt_t CmdExt ;
IanBenzMaxim 0:33d4e66780c0 372 _i8 ServiceNameAndTextBuffer[NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH];
IanBenzMaxim 0:33d4e66780c0 373 _i8 *TextPtr;
IanBenzMaxim 0:33d4e66780c0 374
IanBenzMaxim 0:33d4e66780c0 375 /* verify no erorr handling in progress. if in progress than
IanBenzMaxim 0:33d4e66780c0 376 ignore the API execution and return immediately with an error */
IanBenzMaxim 0:33d4e66780c0 377 VERIFY_NO_ERROR_HANDLING_IN_PROGRESS();
IanBenzMaxim 0:33d4e66780c0 378 /*
IanBenzMaxim 0:33d4e66780c0 379
IanBenzMaxim 0:33d4e66780c0 380 NOTE - pay attention
IanBenzMaxim 0:33d4e66780c0 381
IanBenzMaxim 0:33d4e66780c0 382 1. Temporary - there is an allocation on stack of internal buffer.
IanBenzMaxim 0:33d4e66780c0 383 Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
IanBenzMaxim 0:33d4e66780c0 384 It means that the sum of the text length and service name length cannot be bigger than
IanBenzMaxim 0:33d4e66780c0 385 NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
IanBenzMaxim 0:33d4e66780c0 386 If it is - An error is returned.
IanBenzMaxim 0:33d4e66780c0 387
IanBenzMaxim 0:33d4e66780c0 388 2. According to now from certain constraints the variables parameters are set in the
IanBenzMaxim 0:33d4e66780c0 389 attribute part (contain constant parameters)
IanBenzMaxim 0:33d4e66780c0 390
IanBenzMaxim 0:33d4e66780c0 391
IanBenzMaxim 0:33d4e66780c0 392 */
IanBenzMaxim 0:33d4e66780c0 393
IanBenzMaxim 0:33d4e66780c0 394 /*build the attribute part of the command.
IanBenzMaxim 0:33d4e66780c0 395 It contains the constant parameters of the command*/
IanBenzMaxim 0:33d4e66780c0 396
IanBenzMaxim 0:33d4e66780c0 397 Msg.Cmd.ServiceNameLen = ServiceNameLen;
IanBenzMaxim 0:33d4e66780c0 398 Msg.Cmd.Options = Options;
IanBenzMaxim 0:33d4e66780c0 399 Msg.Cmd.Port = Port;
IanBenzMaxim 0:33d4e66780c0 400 Msg.Cmd.TextLen = TextLen;
IanBenzMaxim 0:33d4e66780c0 401 Msg.Cmd.TTL = TTL;
IanBenzMaxim 0:33d4e66780c0 402
IanBenzMaxim 0:33d4e66780c0 403 /*Build the payload part of the command
IanBenzMaxim 0:33d4e66780c0 404 Copy the service name and text to one buffer.
IanBenzMaxim 0:33d4e66780c0 405 NOTE - pay attention
IanBenzMaxim 0:33d4e66780c0 406 The size of the service length + the text length should be smaller than 255,
IanBenzMaxim 0:33d4e66780c0 407 Until the simplelink drive supports to variable length through SPI command. */
IanBenzMaxim 0:33d4e66780c0 408 if(TextLen + ServiceNameLen > (NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH - 1 )) /*-1 is for giving a place to set null termination at the end of the text*/
IanBenzMaxim 0:33d4e66780c0 409 {
IanBenzMaxim 0:33d4e66780c0 410 return -1;
IanBenzMaxim 0:33d4e66780c0 411 }
IanBenzMaxim 0:33d4e66780c0 412
IanBenzMaxim 0:33d4e66780c0 413 _SlDrvMemZero(ServiceNameAndTextBuffer, (_u16)NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH);
IanBenzMaxim 0:33d4e66780c0 414
IanBenzMaxim 0:33d4e66780c0 415
IanBenzMaxim 0:33d4e66780c0 416 /*Copy the service name*/
IanBenzMaxim 0:33d4e66780c0 417 sl_Memcpy(ServiceNameAndTextBuffer,
IanBenzMaxim 0:33d4e66780c0 418 pServiceName,
IanBenzMaxim 0:33d4e66780c0 419 ServiceNameLen);
IanBenzMaxim 0:33d4e66780c0 420
IanBenzMaxim 0:33d4e66780c0 421 if(TextLen > 0 )
IanBenzMaxim 0:33d4e66780c0 422 {
IanBenzMaxim 0:33d4e66780c0 423
IanBenzMaxim 0:33d4e66780c0 424 TextPtr = &ServiceNameAndTextBuffer[ServiceNameLen];
IanBenzMaxim 0:33d4e66780c0 425 /*Copy the text just after the service name*/
IanBenzMaxim 0:33d4e66780c0 426 sl_Memcpy(TextPtr,
IanBenzMaxim 0:33d4e66780c0 427 pText,
IanBenzMaxim 0:33d4e66780c0 428 TextLen);
IanBenzMaxim 0:33d4e66780c0 429
IanBenzMaxim 0:33d4e66780c0 430
IanBenzMaxim 0:33d4e66780c0 431 }
IanBenzMaxim 0:33d4e66780c0 432
IanBenzMaxim 0:33d4e66780c0 433 _SlDrvResetCmdExt(&CmdExt);
IanBenzMaxim 0:33d4e66780c0 434 CmdExt.TxPayloadLen = (TextLen + ServiceNameLen);
IanBenzMaxim 0:33d4e66780c0 435 CmdExt.pTxPayload = (_u8 *)ServiceNameAndTextBuffer;
IanBenzMaxim 0:33d4e66780c0 436
IanBenzMaxim 0:33d4e66780c0 437
IanBenzMaxim 0:33d4e66780c0 438 VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlRegisterServiceCtrl, &Msg, &CmdExt));
IanBenzMaxim 0:33d4e66780c0 439
IanBenzMaxim 0:33d4e66780c0 440 return (_i16)Msg.Rsp.status;
IanBenzMaxim 0:33d4e66780c0 441
IanBenzMaxim 0:33d4e66780c0 442
IanBenzMaxim 0:33d4e66780c0 443 }
IanBenzMaxim 0:33d4e66780c0 444 #endif
IanBenzMaxim 0:33d4e66780c0 445
IanBenzMaxim 0:33d4e66780c0 446 /**********************************************************************************************/
IanBenzMaxim 0:33d4e66780c0 447 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSRegisterService)
IanBenzMaxim 0:33d4e66780c0 448
IanBenzMaxim 0:33d4e66780c0 449 _i16 sl_NetAppMDNSRegisterService( const _i8* pServiceName,
IanBenzMaxim 0:33d4e66780c0 450 const _u8 ServiceNameLen,
IanBenzMaxim 0:33d4e66780c0 451 const _i8* pText,
IanBenzMaxim 0:33d4e66780c0 452 const _u8 TextLen,
IanBenzMaxim 0:33d4e66780c0 453 const _u16 Port,
IanBenzMaxim 0:33d4e66780c0 454 const _u32 TTL,
IanBenzMaxim 0:33d4e66780c0 455 _u32 Options)
IanBenzMaxim 0:33d4e66780c0 456
IanBenzMaxim 0:33d4e66780c0 457 {
IanBenzMaxim 0:33d4e66780c0 458
IanBenzMaxim 0:33d4e66780c0 459 /* verify no erorr handling in progress. if in progress than
IanBenzMaxim 0:33d4e66780c0 460 ignore the API execution and return immediately with an error */
IanBenzMaxim 0:33d4e66780c0 461 VERIFY_NO_ERROR_HANDLING_IN_PROGRESS();
IanBenzMaxim 0:33d4e66780c0 462
IanBenzMaxim 0:33d4e66780c0 463 /*
IanBenzMaxim 0:33d4e66780c0 464
IanBenzMaxim 0:33d4e66780c0 465 NOTE - pay attention
IanBenzMaxim 0:33d4e66780c0 466
IanBenzMaxim 0:33d4e66780c0 467 1. Temporary - there is an allocation on stack of internal buffer.
IanBenzMaxim 0:33d4e66780c0 468 Its size is NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
IanBenzMaxim 0:33d4e66780c0 469 It means that the sum of the text length and service name length cannot be bigger than
IanBenzMaxim 0:33d4e66780c0 470 NETAPP_MDNS_MAX_SERVICE_NAME_AND_TEXT_LENGTH.
IanBenzMaxim 0:33d4e66780c0 471 If it is - An error is returned.
IanBenzMaxim 0:33d4e66780c0 472
IanBenzMaxim 0:33d4e66780c0 473 2. According to now from certain constraints the variables parameters are set in the
IanBenzMaxim 0:33d4e66780c0 474 attribute part (contain constant parameters)
IanBenzMaxim 0:33d4e66780c0 475
IanBenzMaxim 0:33d4e66780c0 476 */
IanBenzMaxim 0:33d4e66780c0 477
IanBenzMaxim 0:33d4e66780c0 478 /*Set the add service bit in the options parameter.
IanBenzMaxim 0:33d4e66780c0 479 In order not use different opcodes for the register service and unregister service
IanBenzMaxim 0:33d4e66780c0 480 bit 31 in option is taken for this purpose. if it is set it means in NWP that the service should be added
IanBenzMaxim 0:33d4e66780c0 481 if it is cleared it means that the service should be deleted and there is only meaning to pServiceName
IanBenzMaxim 0:33d4e66780c0 482 and ServiceNameLen values. */
IanBenzMaxim 0:33d4e66780c0 483 Options |= NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT;
IanBenzMaxim 0:33d4e66780c0 484
IanBenzMaxim 0:33d4e66780c0 485 return sl_NetAppMDNSRegisterUnregisterService( pServiceName,
IanBenzMaxim 0:33d4e66780c0 486 ServiceNameLen,
IanBenzMaxim 0:33d4e66780c0 487 pText,
IanBenzMaxim 0:33d4e66780c0 488 TextLen,
IanBenzMaxim 0:33d4e66780c0 489 Port,
IanBenzMaxim 0:33d4e66780c0 490 TTL,
IanBenzMaxim 0:33d4e66780c0 491 Options);
IanBenzMaxim 0:33d4e66780c0 492
IanBenzMaxim 0:33d4e66780c0 493
IanBenzMaxim 0:33d4e66780c0 494 }
IanBenzMaxim 0:33d4e66780c0 495 #endif
IanBenzMaxim 0:33d4e66780c0 496 /**********************************************************************************************/
IanBenzMaxim 0:33d4e66780c0 497
IanBenzMaxim 0:33d4e66780c0 498
IanBenzMaxim 0:33d4e66780c0 499
IanBenzMaxim 0:33d4e66780c0 500 /**********************************************************************************************/
IanBenzMaxim 0:33d4e66780c0 501 #if _SL_INCLUDE_FUNC(sl_NetAppMDNSUnRegisterService)
IanBenzMaxim 0:33d4e66780c0 502
IanBenzMaxim 0:33d4e66780c0 503 _i16 sl_NetAppMDNSUnRegisterService( const _i8* pServiceName,
IanBenzMaxim 0:33d4e66780c0 504 const _u8 ServiceNameLen)
IanBenzMaxim 0:33d4e66780c0 505
IanBenzMaxim 0:33d4e66780c0 506
IanBenzMaxim 0:33d4e66780c0 507 {
IanBenzMaxim 0:33d4e66780c0 508 _u32 Options = 0;
IanBenzMaxim 0:33d4e66780c0 509
IanBenzMaxim 0:33d4e66780c0 510 /* verify no erorr handling in progress. if in progress than
IanBenzMaxim 0:33d4e66780c0 511 ignore the API execution and return immediately with an error */
IanBenzMaxim 0:33d4e66780c0 512 VERIFY_NO_ERROR_HANDLING_IN_PROGRESS();
IanBenzMaxim 0:33d4e66780c0 513
IanBenzMaxim 0:33d4e66780c0 514 /*
IanBenzMaxim 0:33d4e66780c0 515
IanBenzMaxim 0:33d4e66780c0 516 NOTE - pay attention
IanBenzMaxim 0:33d4e66780c0 517
IanBenzMaxim 0:33d4e66780c0 518 The size of the service length should be smaller than 255,
IanBenzMaxim 0:33d4e66780c0 519 Until the simplelink drive supports to variable length through SPI command.
IanBenzMaxim 0:33d4e66780c0 520
IanBenzMaxim 0:33d4e66780c0 521
IanBenzMaxim 0:33d4e66780c0 522 */
IanBenzMaxim 0:33d4e66780c0 523
IanBenzMaxim 0:33d4e66780c0 524 /*Clear the add service bit in the options parameter.
IanBenzMaxim 0:33d4e66780c0 525 In order not use different opcodes for the register service and unregister service
IanBenzMaxim 0:33d4e66780c0 526 bit 31 in option is taken for this purpose. if it is set it means in NWP that the service should be added
IanBenzMaxim 0:33d4e66780c0 527 if it is cleared it means that the service should be deleted and there is only meaning to pServiceName
IanBenzMaxim 0:33d4e66780c0 528 and ServiceNameLen values.*/
IanBenzMaxim 0:33d4e66780c0 529
IanBenzMaxim 0:33d4e66780c0 530 Options &= (~NETAPP_MDNS_OPTIONS_ADD_SERVICE_BIT);
IanBenzMaxim 0:33d4e66780c0 531
IanBenzMaxim 0:33d4e66780c0 532 return sl_NetAppMDNSRegisterUnregisterService( pServiceName,
IanBenzMaxim 0:33d4e66780c0 533 ServiceNameLen,
IanBenzMaxim 0:33d4e66780c0 534 NULL,
IanBenzMaxim 0:33d4e66780c0 535 0,
IanBenzMaxim 0:33d4e66780c0 536 0,
IanBenzMaxim 0:33d4e66780c0 537 0,
IanBenzMaxim 0:33d4e66780c0 538 Options);
IanBenzMaxim 0:33d4e66780c0 539
IanBenzMaxim 0:33d4e66780c0 540
IanBenzMaxim 0:33d4e66780c0 541 }
IanBenzMaxim 0:33d4e66780c0 542 #endif
IanBenzMaxim 0:33d4e66780c0 543 /**********************************************************************************************/
IanBenzMaxim 0:33d4e66780c0 544
IanBenzMaxim 0:33d4e66780c0 545
IanBenzMaxim 0:33d4e66780c0 546
IanBenzMaxim 0:33d4e66780c0 547 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 548 /* sl_DnsGetHostByService */
IanBenzMaxim 0:33d4e66780c0 549 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 550 /*
IanBenzMaxim 0:33d4e66780c0 551 * The below struct depicts the constant parameters of the command/API sl_DnsGetHostByService.
IanBenzMaxim 0:33d4e66780c0 552 *
IanBenzMaxim 0:33d4e66780c0 553 1. ServiceLen - The length of the service should be smaller than 255.
IanBenzMaxim 0:33d4e66780c0 554 2. AddrLen - TIPv4 or IPv6 (SL_AF_INET , SL_AF_INET6).
IanBenzMaxim 0:33d4e66780c0 555 *
IanBenzMaxim 0:33d4e66780c0 556 */
IanBenzMaxim 0:33d4e66780c0 557
IanBenzMaxim 0:33d4e66780c0 558 typedef struct
IanBenzMaxim 0:33d4e66780c0 559 {
IanBenzMaxim 0:33d4e66780c0 560 _u8 ServiceLen;
IanBenzMaxim 0:33d4e66780c0 561 _u8 AddrLen;
IanBenzMaxim 0:33d4e66780c0 562 _u16 Padding;
IanBenzMaxim 0:33d4e66780c0 563 }_GetHostByServiceCommand_t;
IanBenzMaxim 0:33d4e66780c0 564
IanBenzMaxim 0:33d4e66780c0 565
IanBenzMaxim 0:33d4e66780c0 566
IanBenzMaxim 0:33d4e66780c0 567 /*
IanBenzMaxim 0:33d4e66780c0 568 * The below structure depict the constant parameters that are returned in the Async event answer
IanBenzMaxim 0:33d4e66780c0 569 * according to command/API sl_DnsGetHostByService for IPv4 and IPv6.
IanBenzMaxim 0:33d4e66780c0 570 *
IanBenzMaxim 0:33d4e66780c0 571 1Status - The status of the response.
IanBenzMaxim 0:33d4e66780c0 572 2.Address - Contains the IP address of the service.
IanBenzMaxim 0:33d4e66780c0 573 3.Port - Contains the port of the service.
IanBenzMaxim 0:33d4e66780c0 574 4.TextLen - Contains the max length of the text that the user wants to get.
IanBenzMaxim 0:33d4e66780c0 575 it means that if the test of service is bigger that its value than
IanBenzMaxim 0:33d4e66780c0 576 the text is cut to inout_TextLen value.
IanBenzMaxim 0:33d4e66780c0 577 Output: Contain the length of the text that is returned. Can be full text or part
IanBenzMaxim 0:33d4e66780c0 578 of the text (see above).
IanBenzMaxim 0:33d4e66780c0 579
IanBenzMaxim 0:33d4e66780c0 580 *
IanBenzMaxim 0:33d4e66780c0 581 */
IanBenzMaxim 0:33d4e66780c0 582 typedef struct
IanBenzMaxim 0:33d4e66780c0 583 {
IanBenzMaxim 0:33d4e66780c0 584 _u16 Status;
IanBenzMaxim 0:33d4e66780c0 585 _u16 TextLen;
IanBenzMaxim 0:33d4e66780c0 586 _u32 Port;
IanBenzMaxim 0:33d4e66780c0 587 _u32 Address;
IanBenzMaxim 0:33d4e66780c0 588 }_GetHostByServiceIPv4AsyncResponse_t;
IanBenzMaxim 0:33d4e66780c0 589
IanBenzMaxim 0:33d4e66780c0 590
IanBenzMaxim 0:33d4e66780c0 591 typedef struct
IanBenzMaxim 0:33d4e66780c0 592 {
IanBenzMaxim 0:33d4e66780c0 593 _u16 Status;
IanBenzMaxim 0:33d4e66780c0 594 _u16 TextLen;
IanBenzMaxim 0:33d4e66780c0 595 _u32 Port;
IanBenzMaxim 0:33d4e66780c0 596 _u32 Address[4];
IanBenzMaxim 0:33d4e66780c0 597 }_GetHostByServiceIPv6AsyncResponse_t;
IanBenzMaxim 0:33d4e66780c0 598
IanBenzMaxim 0:33d4e66780c0 599
IanBenzMaxim 0:33d4e66780c0 600 typedef union
IanBenzMaxim 0:33d4e66780c0 601 {
IanBenzMaxim 0:33d4e66780c0 602 _GetHostByServiceIPv4AsyncResponse_t IpV4;
IanBenzMaxim 0:33d4e66780c0 603 _GetHostByServiceIPv6AsyncResponse_t IpV6;
IanBenzMaxim 0:33d4e66780c0 604 }_GetHostByServiceAsyncResponseAttribute_u;
IanBenzMaxim 0:33d4e66780c0 605
IanBenzMaxim 0:33d4e66780c0 606 /*
IanBenzMaxim 0:33d4e66780c0 607 * The below struct contains pointers to the output parameters that the user gives
IanBenzMaxim 0:33d4e66780c0 608 *
IanBenzMaxim 0:33d4e66780c0 609 */
IanBenzMaxim 0:33d4e66780c0 610 typedef struct
IanBenzMaxim 0:33d4e66780c0 611 {
IanBenzMaxim 0:33d4e66780c0 612 _i16 Status;
IanBenzMaxim 0:33d4e66780c0 613 _u32 *out_pAddr;
IanBenzMaxim 0:33d4e66780c0 614 _u32 *out_pPort;
IanBenzMaxim 0:33d4e66780c0 615 _u16 *inout_TextLen; /* in: max len , out: actual len */
IanBenzMaxim 0:33d4e66780c0 616 _i8 *out_pText;
IanBenzMaxim 0:33d4e66780c0 617 }_GetHostByServiceAsyncResponse_t;
IanBenzMaxim 0:33d4e66780c0 618
IanBenzMaxim 0:33d4e66780c0 619
IanBenzMaxim 0:33d4e66780c0 620 typedef union
IanBenzMaxim 0:33d4e66780c0 621 {
IanBenzMaxim 0:33d4e66780c0 622 _GetHostByServiceCommand_t Cmd;
IanBenzMaxim 0:33d4e66780c0 623 _BasicResponse_t Rsp;
IanBenzMaxim 0:33d4e66780c0 624 }_SlGetHostByServiceMsg_u;
IanBenzMaxim 0:33d4e66780c0 625
IanBenzMaxim 0:33d4e66780c0 626
IanBenzMaxim 0:33d4e66780c0 627 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByService)
IanBenzMaxim 0:33d4e66780c0 628
IanBenzMaxim 0:33d4e66780c0 629 static const _SlCmdCtrl_t _SlGetHostByServiceCtrl =
IanBenzMaxim 0:33d4e66780c0 630 {
IanBenzMaxim 0:33d4e66780c0 631 SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICE,
IanBenzMaxim 0:33d4e66780c0 632 (_SlArgSize_t)sizeof(_GetHostByServiceCommand_t),
IanBenzMaxim 0:33d4e66780c0 633 (_SlArgSize_t)sizeof(_BasicResponse_t)
IanBenzMaxim 0:33d4e66780c0 634 };
IanBenzMaxim 0:33d4e66780c0 635
IanBenzMaxim 0:33d4e66780c0 636 /******************************************************************************/
IanBenzMaxim 0:33d4e66780c0 637
IanBenzMaxim 0:33d4e66780c0 638 _i32 sl_NetAppDnsGetHostByService(_i8 *pServiceName, /* string containing all (or only part): name + subtype + service */
IanBenzMaxim 0:33d4e66780c0 639 const _u8 ServiceLen,
IanBenzMaxim 0:33d4e66780c0 640 const _u8 Family, /* 4-IPv4 , 16-IPv6 */
IanBenzMaxim 0:33d4e66780c0 641 _u32 pAddr[],
IanBenzMaxim 0:33d4e66780c0 642 _u32 *pPort,
IanBenzMaxim 0:33d4e66780c0 643 _u16 *pTextLen, /* in: max len , out: actual len */
IanBenzMaxim 0:33d4e66780c0 644 _i8 *pText
IanBenzMaxim 0:33d4e66780c0 645 )
IanBenzMaxim 0:33d4e66780c0 646 {
IanBenzMaxim 0:33d4e66780c0 647 _SlGetHostByServiceMsg_u Msg;
IanBenzMaxim 0:33d4e66780c0 648 _SlCmdExt_t CmdExt ;
IanBenzMaxim 0:33d4e66780c0 649 _GetHostByServiceAsyncResponse_t AsyncRsp;
IanBenzMaxim 0:33d4e66780c0 650 _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
IanBenzMaxim 0:33d4e66780c0 651
IanBenzMaxim 0:33d4e66780c0 652 /* verify no erorr handling in progress. if in progress than
IanBenzMaxim 0:33d4e66780c0 653 ignore the API execution and return immediately with an error */
IanBenzMaxim 0:33d4e66780c0 654 VERIFY_NO_ERROR_HANDLING_IN_PROGRESS();
IanBenzMaxim 0:33d4e66780c0 655
IanBenzMaxim 0:33d4e66780c0 656 /*
IanBenzMaxim 0:33d4e66780c0 657 Note:
IanBenzMaxim 0:33d4e66780c0 658 1. The return's attributes are belonged to first service that is found.
IanBenzMaxim 0:33d4e66780c0 659 It can be other services with the same service name will response to
IanBenzMaxim 0:33d4e66780c0 660 the query. The results of these responses are saved in the peer cache of the NWP, and
IanBenzMaxim 0:33d4e66780c0 661 should be read by another API.
IanBenzMaxim 0:33d4e66780c0 662
IanBenzMaxim 0:33d4e66780c0 663 2. Text length can be 120 bytes only - not more
IanBenzMaxim 0:33d4e66780c0 664 It is because of constraints in the NWP on the buffer that is allocated for the Async event.
IanBenzMaxim 0:33d4e66780c0 665
IanBenzMaxim 0:33d4e66780c0 666 3.The API waits to Async event by blocking. It means that the API is finished only after an Async event
IanBenzMaxim 0:33d4e66780c0 667 is sent by the NWP.
IanBenzMaxim 0:33d4e66780c0 668
IanBenzMaxim 0:33d4e66780c0 669 4.No rolling option!!! - only PTR type is sent.
IanBenzMaxim 0:33d4e66780c0 670
IanBenzMaxim 0:33d4e66780c0 671
IanBenzMaxim 0:33d4e66780c0 672 */
IanBenzMaxim 0:33d4e66780c0 673 /*build the attribute part of the command.
IanBenzMaxim 0:33d4e66780c0 674 It contains the constant parameters of the command */
IanBenzMaxim 0:33d4e66780c0 675
IanBenzMaxim 0:33d4e66780c0 676 Msg.Cmd.ServiceLen = ServiceLen;
IanBenzMaxim 0:33d4e66780c0 677 Msg.Cmd.AddrLen = Family;
IanBenzMaxim 0:33d4e66780c0 678
IanBenzMaxim 0:33d4e66780c0 679 /*Build the payload part of the command
IanBenzMaxim 0:33d4e66780c0 680 Copy the service name and text to one buffer.*/
IanBenzMaxim 0:33d4e66780c0 681
IanBenzMaxim 0:33d4e66780c0 682 _SlDrvResetCmdExt(&CmdExt);
IanBenzMaxim 0:33d4e66780c0 683 CmdExt.TxPayloadLen = ServiceLen;
IanBenzMaxim 0:33d4e66780c0 684 CmdExt.pTxPayload = (_u8 *)pServiceName;
IanBenzMaxim 0:33d4e66780c0 685
IanBenzMaxim 0:33d4e66780c0 686 /*set pointers to the output parameters (the returned parameters).
IanBenzMaxim 0:33d4e66780c0 687 This pointers are belonged to local struct that is set to global Async response parameter.
IanBenzMaxim 0:33d4e66780c0 688 It is done in order not to run more than one sl_DnsGetHostByService at the same time.
IanBenzMaxim 0:33d4e66780c0 689 The API should be run only if global parameter is pointed to NULL. */
IanBenzMaxim 0:33d4e66780c0 690 AsyncRsp.out_pText = pText;
IanBenzMaxim 0:33d4e66780c0 691 AsyncRsp.inout_TextLen = (_u16* )pTextLen;
IanBenzMaxim 0:33d4e66780c0 692 AsyncRsp.out_pPort = pPort;
IanBenzMaxim 0:33d4e66780c0 693 AsyncRsp.out_pAddr = (_u32 *)pAddr;
IanBenzMaxim 0:33d4e66780c0 694
IanBenzMaxim 0:33d4e66780c0 695
IanBenzMaxim 0:33d4e66780c0 696 ObjIdx = _SlDrvProtectAsyncRespSetting((_u8*)&AsyncRsp, GETHOSYBYSERVICE_ID, SL_MAX_SOCKETS);
IanBenzMaxim 0:33d4e66780c0 697
IanBenzMaxim 0:33d4e66780c0 698 if (MAX_CONCURRENT_ACTIONS == ObjIdx)
IanBenzMaxim 0:33d4e66780c0 699 {
IanBenzMaxim 0:33d4e66780c0 700 return SL_POOL_IS_EMPTY;
IanBenzMaxim 0:33d4e66780c0 701 }
IanBenzMaxim 0:33d4e66780c0 702
IanBenzMaxim 0:33d4e66780c0 703
IanBenzMaxim 0:33d4e66780c0 704 if (SL_AF_INET6 == Family)
IanBenzMaxim 0:33d4e66780c0 705 {
IanBenzMaxim 0:33d4e66780c0 706 g_pCB->ObjPool[ObjIdx].AdditionalData |= SL_NETAPP_FAMILY_MASK;
IanBenzMaxim 0:33d4e66780c0 707 }
IanBenzMaxim 0:33d4e66780c0 708 /* Send the command */
IanBenzMaxim 0:33d4e66780c0 709 VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetHostByServiceCtrl, &Msg, &CmdExt));
IanBenzMaxim 0:33d4e66780c0 710
IanBenzMaxim 0:33d4e66780c0 711
IanBenzMaxim 0:33d4e66780c0 712
IanBenzMaxim 0:33d4e66780c0 713 /* If the immediate reponse is O.K. than wait for aSYNC event response. */
IanBenzMaxim 0:33d4e66780c0 714 if(SL_RET_CODE_OK == Msg.Rsp.status)
IanBenzMaxim 0:33d4e66780c0 715 {
IanBenzMaxim 0:33d4e66780c0 716 SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->ObjPool[ObjIdx].SyncObj);
IanBenzMaxim 0:33d4e66780c0 717
IanBenzMaxim 0:33d4e66780c0 718 /* If we are - it means that Async event was sent.
IanBenzMaxim 0:33d4e66780c0 719 The results are copied in the Async handle return functions */
IanBenzMaxim 0:33d4e66780c0 720
IanBenzMaxim 0:33d4e66780c0 721 Msg.Rsp.status = AsyncRsp.Status;
IanBenzMaxim 0:33d4e66780c0 722 }
IanBenzMaxim 0:33d4e66780c0 723
IanBenzMaxim 0:33d4e66780c0 724 _SlDrvReleasePoolObj(ObjIdx);
IanBenzMaxim 0:33d4e66780c0 725 return Msg.Rsp.status;
IanBenzMaxim 0:33d4e66780c0 726 }
IanBenzMaxim 0:33d4e66780c0 727 #endif
IanBenzMaxim 0:33d4e66780c0 728
IanBenzMaxim 0:33d4e66780c0 729 /******************************************************************************/
IanBenzMaxim 0:33d4e66780c0 730
IanBenzMaxim 0:33d4e66780c0 731 /******************************************************************************
IanBenzMaxim 0:33d4e66780c0 732 _sl_HandleAsync_DnsGetHostByService
IanBenzMaxim 0:33d4e66780c0 733
IanBenzMaxim 0:33d4e66780c0 734 CALLER NWP - Async event on sl_DnsGetHostByService with IPv4 Family
IanBenzMaxim 0:33d4e66780c0 735
IanBenzMaxim 0:33d4e66780c0 736
IanBenzMaxim 0:33d4e66780c0 737 DESCRIPTION:
IanBenzMaxim 0:33d4e66780c0 738
IanBenzMaxim 0:33d4e66780c0 739 Async event on sl_DnsGetHostByService command with IPv4 Family.
IanBenzMaxim 0:33d4e66780c0 740 Return service attributes like IP address, port and text according to service name.
IanBenzMaxim 0:33d4e66780c0 741 The user sets a service name Full/Part (see example below), and should get the:
IanBenzMaxim 0:33d4e66780c0 742 1. IP of the service
IanBenzMaxim 0:33d4e66780c0 743 2. The port of service.
IanBenzMaxim 0:33d4e66780c0 744 3. The text of service.
IanBenzMaxim 0:33d4e66780c0 745
IanBenzMaxim 0:33d4e66780c0 746 Hence it can make a connection to the specific service and use it.
IanBenzMaxim 0:33d4e66780c0 747 It is similar to get host by name method.
IanBenzMaxim 0:33d4e66780c0 748
IanBenzMaxim 0:33d4e66780c0 749 It is done by a single shot query with PTR type on the service name.
IanBenzMaxim 0:33d4e66780c0 750
IanBenzMaxim 0:33d4e66780c0 751
IanBenzMaxim 0:33d4e66780c0 752
IanBenzMaxim 0:33d4e66780c0 753 Note:
IanBenzMaxim 0:33d4e66780c0 754 1. The return's attributes are belonged to first service that is found.
IanBenzMaxim 0:33d4e66780c0 755 It can be other services with the same service name will response to
IanBenzMaxim 0:33d4e66780c0 756 the query. The results of these responses are saved in the peer cache of the NWP, and
IanBenzMaxim 0:33d4e66780c0 757 should be read by another API.
IanBenzMaxim 0:33d4e66780c0 758
IanBenzMaxim 0:33d4e66780c0 759
IanBenzMaxim 0:33d4e66780c0 760 PARAMETERS:
IanBenzMaxim 0:33d4e66780c0 761
IanBenzMaxim 0:33d4e66780c0 762 pVoidBuf - is point to opcode of the event.
IanBenzMaxim 0:33d4e66780c0 763 it contains the outputs that are given to the user
IanBenzMaxim 0:33d4e66780c0 764
IanBenzMaxim 0:33d4e66780c0 765 outputs description:
IanBenzMaxim 0:33d4e66780c0 766
IanBenzMaxim 0:33d4e66780c0 767 1.out_pAddr[] - output: Contain the IP address of the service.
IanBenzMaxim 0:33d4e66780c0 768 2.out_pPort - output: Contain the port of the service.
IanBenzMaxim 0:33d4e66780c0 769 3.inout_TextLen - Input: Contain the max length of the text that the user wants to get.
IanBenzMaxim 0:33d4e66780c0 770 it means that if the test of service is bigger that its value than
IanBenzMaxim 0:33d4e66780c0 771 the text is cut to inout_TextLen value.
IanBenzMaxim 0:33d4e66780c0 772 Output: Contain the length of the text that is returned. Can be full text or part
IanBenzMaxim 0:33d4e66780c0 773 of the text (see above).
IanBenzMaxim 0:33d4e66780c0 774
IanBenzMaxim 0:33d4e66780c0 775 4.out_pText - Contain the text of the service (full or part see above- inout_TextLen description).
IanBenzMaxim 0:33d4e66780c0 776
IanBenzMaxim 0:33d4e66780c0 777 *
IanBenzMaxim 0:33d4e66780c0 778
IanBenzMaxim 0:33d4e66780c0 779
IanBenzMaxim 0:33d4e66780c0 780 RETURNS: success or fail.
IanBenzMaxim 0:33d4e66780c0 781
IanBenzMaxim 0:33d4e66780c0 782
IanBenzMaxim 0:33d4e66780c0 783
IanBenzMaxim 0:33d4e66780c0 784
IanBenzMaxim 0:33d4e66780c0 785
IanBenzMaxim 0:33d4e66780c0 786 ******************************************************************************/
IanBenzMaxim 0:33d4e66780c0 787 #ifndef SL_TINY_EXT
IanBenzMaxim 0:33d4e66780c0 788 _SlReturnVal_t _sl_HandleAsync_DnsGetHostByService(void *pVoidBuf)
IanBenzMaxim 0:33d4e66780c0 789 {
IanBenzMaxim 0:33d4e66780c0 790
IanBenzMaxim 0:33d4e66780c0 791 _GetHostByServiceAsyncResponse_t* Res;
IanBenzMaxim 0:33d4e66780c0 792 _u16 TextLen;
IanBenzMaxim 0:33d4e66780c0 793 _u16 UserTextLen;
IanBenzMaxim 0:33d4e66780c0 794
IanBenzMaxim 0:33d4e66780c0 795
IanBenzMaxim 0:33d4e66780c0 796 /*pVoidBuf - is point to opcode of the event.*/
IanBenzMaxim 0:33d4e66780c0 797
IanBenzMaxim 0:33d4e66780c0 798 /*set pMsgArgs to point to the attribute of the event.*/
IanBenzMaxim 0:33d4e66780c0 799 _GetHostByServiceIPv4AsyncResponse_t *pMsgArgs = (_GetHostByServiceIPv4AsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf);
IanBenzMaxim 0:33d4e66780c0 800
IanBenzMaxim 0:33d4e66780c0 801 VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs);
IanBenzMaxim 0:33d4e66780c0 802
IanBenzMaxim 0:33d4e66780c0 803 /*IPv6*/
IanBenzMaxim 0:33d4e66780c0 804 if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK)
IanBenzMaxim 0:33d4e66780c0 805 {
IanBenzMaxim 0:33d4e66780c0 806 return SL_RET_CODE_OK;
IanBenzMaxim 0:33d4e66780c0 807 }
IanBenzMaxim 0:33d4e66780c0 808 /*IPv4*/
IanBenzMaxim 0:33d4e66780c0 809 else
IanBenzMaxim 0:33d4e66780c0 810 {
IanBenzMaxim 0:33d4e66780c0 811 /*************************************************************************************************
IanBenzMaxim 0:33d4e66780c0 812
IanBenzMaxim 0:33d4e66780c0 813 1. Copy the attribute part of the evnt to the attribute part of the response
IanBenzMaxim 0:33d4e66780c0 814 sl_Memcpy(g_pCB->GetHostByServiceCB.pAsyncRsp, pMsgArgs, sizeof(_GetHostByServiceIPv4AsyncResponse_t));
IanBenzMaxim 0:33d4e66780c0 815
IanBenzMaxim 0:33d4e66780c0 816 set to TextLen the text length of the service.*/
IanBenzMaxim 0:33d4e66780c0 817 TextLen = pMsgArgs->TextLen;
IanBenzMaxim 0:33d4e66780c0 818
IanBenzMaxim 0:33d4e66780c0 819 /*Res pointed to mDNS global object struct */
IanBenzMaxim 0:33d4e66780c0 820 Res = (_GetHostByServiceAsyncResponse_t*)g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs;
IanBenzMaxim 0:33d4e66780c0 821
IanBenzMaxim 0:33d4e66780c0 822
IanBenzMaxim 0:33d4e66780c0 823
IanBenzMaxim 0:33d4e66780c0 824 /*It is 4 bytes so we avoid from memcpy*/
IanBenzMaxim 0:33d4e66780c0 825 Res->out_pAddr[0] = pMsgArgs->Address;
IanBenzMaxim 0:33d4e66780c0 826 Res->out_pPort[0] = pMsgArgs->Port;
IanBenzMaxim 0:33d4e66780c0 827 Res->Status = (_i16)pMsgArgs->Status;
IanBenzMaxim 0:33d4e66780c0 828
IanBenzMaxim 0:33d4e66780c0 829 /*set to TextLen the text length of the user (input fromthe user).*/
IanBenzMaxim 0:33d4e66780c0 830 UserTextLen = Res->inout_TextLen[0];
IanBenzMaxim 0:33d4e66780c0 831
IanBenzMaxim 0:33d4e66780c0 832 /*Cut the service text if the user requested for smaller text.*/
IanBenzMaxim 0:33d4e66780c0 833 UserTextLen = (TextLen <= UserTextLen) ? TextLen : UserTextLen;
IanBenzMaxim 0:33d4e66780c0 834 Res->inout_TextLen[0] = UserTextLen ;
IanBenzMaxim 0:33d4e66780c0 835
IanBenzMaxim 0:33d4e66780c0 836 /**************************************************************************************************
IanBenzMaxim 0:33d4e66780c0 837
IanBenzMaxim 0:33d4e66780c0 838 2. Copy the payload part of the evnt (the text) to the payload part of the response
IanBenzMaxim 0:33d4e66780c0 839 the lenght of the copy is according to the text length in the attribute part. */
IanBenzMaxim 0:33d4e66780c0 840
IanBenzMaxim 0:33d4e66780c0 841
IanBenzMaxim 0:33d4e66780c0 842 sl_Memcpy(Res->out_pText ,
IanBenzMaxim 0:33d4e66780c0 843 (_i8 *)(& pMsgArgs[1]) , /* & pMsgArgs[1] -> 1st byte after the fixed header = 1st byte of variable text.*/
IanBenzMaxim 0:33d4e66780c0 844 UserTextLen );
IanBenzMaxim 0:33d4e66780c0 845
IanBenzMaxim 0:33d4e66780c0 846
IanBenzMaxim 0:33d4e66780c0 847 /**************************************************************************************************/
IanBenzMaxim 0:33d4e66780c0 848
IanBenzMaxim 0:33d4e66780c0 849 SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj);
IanBenzMaxim 0:33d4e66780c0 850 return SL_RET_CODE_OK;
IanBenzMaxim 0:33d4e66780c0 851 }
IanBenzMaxim 0:33d4e66780c0 852 }
IanBenzMaxim 0:33d4e66780c0 853
IanBenzMaxim 0:33d4e66780c0 854 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 855 /* _sl_HandleAsync_DnsGetHostByAddr */
IanBenzMaxim 0:33d4e66780c0 856 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 857 _SlReturnVal_t _sl_HandleAsync_DnsGetHostByAddr(void *pVoidBuf)
IanBenzMaxim 0:33d4e66780c0 858 {
IanBenzMaxim 0:33d4e66780c0 859 SL_TRACE0(DBG_MSG, MSG_303, "STUB: _sl_HandleAsync_DnsGetHostByAddr not implemented yet!");
IanBenzMaxim 0:33d4e66780c0 860 (void)pVoidBuf;
IanBenzMaxim 0:33d4e66780c0 861
IanBenzMaxim 0:33d4e66780c0 862 return SL_RET_CODE_OK;
IanBenzMaxim 0:33d4e66780c0 863 }
IanBenzMaxim 0:33d4e66780c0 864 #endif
IanBenzMaxim 0:33d4e66780c0 865
IanBenzMaxim 0:33d4e66780c0 866 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 867 /* sl_DnsGetHostByName */
IanBenzMaxim 0:33d4e66780c0 868 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 869 typedef union
IanBenzMaxim 0:33d4e66780c0 870 {
IanBenzMaxim 0:33d4e66780c0 871 _GetHostByNameIPv4AsyncResponse_t IpV4;
IanBenzMaxim 0:33d4e66780c0 872 _GetHostByNameIPv6AsyncResponse_t IpV6;
IanBenzMaxim 0:33d4e66780c0 873 }_GetHostByNameAsyncResponse_u;
IanBenzMaxim 0:33d4e66780c0 874
IanBenzMaxim 0:33d4e66780c0 875 typedef union
IanBenzMaxim 0:33d4e66780c0 876 {
IanBenzMaxim 0:33d4e66780c0 877 _GetHostByNameCommand_t Cmd;
IanBenzMaxim 0:33d4e66780c0 878 _BasicResponse_t Rsp;
IanBenzMaxim 0:33d4e66780c0 879 }_SlGetHostByNameMsg_u;
IanBenzMaxim 0:33d4e66780c0 880
IanBenzMaxim 0:33d4e66780c0 881
IanBenzMaxim 0:33d4e66780c0 882 #if _SL_INCLUDE_FUNC(sl_NetAppDnsGetHostByName)
IanBenzMaxim 0:33d4e66780c0 883 static const _SlCmdCtrl_t _SlGetHostByNameCtrl =
IanBenzMaxim 0:33d4e66780c0 884 {
IanBenzMaxim 0:33d4e66780c0 885 SL_OPCODE_NETAPP_DNSGETHOSTBYNAME,
IanBenzMaxim 0:33d4e66780c0 886 (_SlArgSize_t)sizeof(_GetHostByNameCommand_t),
IanBenzMaxim 0:33d4e66780c0 887 (_SlArgSize_t)sizeof(_BasicResponse_t)
IanBenzMaxim 0:33d4e66780c0 888 };
IanBenzMaxim 0:33d4e66780c0 889
IanBenzMaxim 0:33d4e66780c0 890 _i16 sl_NetAppDnsGetHostByName(_i8 * hostname,const _u16 usNameLen, _u32* out_ip_addr,const _u8 family)
IanBenzMaxim 0:33d4e66780c0 891 {
IanBenzMaxim 0:33d4e66780c0 892 _SlGetHostByNameMsg_u Msg;
IanBenzMaxim 0:33d4e66780c0 893 _SlCmdExt_t ExtCtrl;
IanBenzMaxim 0:33d4e66780c0 894 _GetHostByNameAsyncResponse_u AsyncRsp;
IanBenzMaxim 0:33d4e66780c0 895 _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
IanBenzMaxim 0:33d4e66780c0 896
IanBenzMaxim 0:33d4e66780c0 897 /* verify no erorr handling in progress. if in progress than
IanBenzMaxim 0:33d4e66780c0 898 ignore the API execution and return immediately with an error */
IanBenzMaxim 0:33d4e66780c0 899 VERIFY_NO_ERROR_HANDLING_IN_PROGRESS();
IanBenzMaxim 0:33d4e66780c0 900
IanBenzMaxim 0:33d4e66780c0 901 _SlDrvResetCmdExt(&ExtCtrl);
IanBenzMaxim 0:33d4e66780c0 902 ExtCtrl.TxPayloadLen = usNameLen;
IanBenzMaxim 0:33d4e66780c0 903 ExtCtrl.pTxPayload = (_u8 *)hostname;
IanBenzMaxim 0:33d4e66780c0 904
IanBenzMaxim 0:33d4e66780c0 905 Msg.Cmd.Len = usNameLen;
IanBenzMaxim 0:33d4e66780c0 906 Msg.Cmd.family = family;
IanBenzMaxim 0:33d4e66780c0 907
IanBenzMaxim 0:33d4e66780c0 908 /*Use Obj to issue the command, if not available try later */
IanBenzMaxim 0:33d4e66780c0 909 ObjIdx = (_u8)_SlDrvWaitForPoolObj(GETHOSYBYNAME_ID,SL_MAX_SOCKETS);
IanBenzMaxim 0:33d4e66780c0 910 if (MAX_CONCURRENT_ACTIONS == ObjIdx)
IanBenzMaxim 0:33d4e66780c0 911 {
IanBenzMaxim 0:33d4e66780c0 912 return SL_POOL_IS_EMPTY;
IanBenzMaxim 0:33d4e66780c0 913 }
IanBenzMaxim 0:33d4e66780c0 914
IanBenzMaxim 0:33d4e66780c0 915 SL_DRV_PROTECTION_OBJ_LOCK_FOREVER();
IanBenzMaxim 0:33d4e66780c0 916
IanBenzMaxim 0:33d4e66780c0 917 g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&AsyncRsp;
IanBenzMaxim 0:33d4e66780c0 918 /*set bit to indicate IPv6 address is expected */
IanBenzMaxim 0:33d4e66780c0 919 if (SL_AF_INET6 == family)
IanBenzMaxim 0:33d4e66780c0 920 {
IanBenzMaxim 0:33d4e66780c0 921 g_pCB->ObjPool[ObjIdx].AdditionalData |= SL_NETAPP_FAMILY_MASK;
IanBenzMaxim 0:33d4e66780c0 922 }
IanBenzMaxim 0:33d4e66780c0 923
IanBenzMaxim 0:33d4e66780c0 924 SL_DRV_PROTECTION_OBJ_UNLOCK();
IanBenzMaxim 0:33d4e66780c0 925
IanBenzMaxim 0:33d4e66780c0 926 VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlGetHostByNameCtrl, &Msg, &ExtCtrl));
IanBenzMaxim 0:33d4e66780c0 927
IanBenzMaxim 0:33d4e66780c0 928 if(SL_RET_CODE_OK == Msg.Rsp.status)
IanBenzMaxim 0:33d4e66780c0 929 {
IanBenzMaxim 0:33d4e66780c0 930 SL_DRV_SYNC_OBJ_WAIT_FOREVER(&g_pCB->ObjPool[ObjIdx].SyncObj);
IanBenzMaxim 0:33d4e66780c0 931
IanBenzMaxim 0:33d4e66780c0 932 Msg.Rsp.status = (_i16)AsyncRsp.IpV4.status;
IanBenzMaxim 0:33d4e66780c0 933
IanBenzMaxim 0:33d4e66780c0 934 if(SL_OS_RET_CODE_OK == (_i16)Msg.Rsp.status)
IanBenzMaxim 0:33d4e66780c0 935 {
IanBenzMaxim 0:33d4e66780c0 936 sl_Memcpy((_i8 *)out_ip_addr,
IanBenzMaxim 0:33d4e66780c0 937 (_i8 *)&AsyncRsp.IpV4.ip0,
IanBenzMaxim 0:33d4e66780c0 938 (SL_AF_INET == family) ? SL_IPV4_ADDRESS_SIZE : SL_IPV6_ADDRESS_SIZE);
IanBenzMaxim 0:33d4e66780c0 939 }
IanBenzMaxim 0:33d4e66780c0 940 }
IanBenzMaxim 0:33d4e66780c0 941 _SlDrvReleasePoolObj(ObjIdx);
IanBenzMaxim 0:33d4e66780c0 942 return Msg.Rsp.status;
IanBenzMaxim 0:33d4e66780c0 943 }
IanBenzMaxim 0:33d4e66780c0 944 #endif
IanBenzMaxim 0:33d4e66780c0 945
IanBenzMaxim 0:33d4e66780c0 946
IanBenzMaxim 0:33d4e66780c0 947 /******************************************************************************/
IanBenzMaxim 0:33d4e66780c0 948 /* _sl_HandleAsync_DnsGetHostByName */
IanBenzMaxim 0:33d4e66780c0 949 /******************************************************************************/
IanBenzMaxim 0:33d4e66780c0 950 _SlReturnVal_t _sl_HandleAsync_DnsGetHostByName(void *pVoidBuf)
IanBenzMaxim 0:33d4e66780c0 951 {
IanBenzMaxim 0:33d4e66780c0 952 _GetHostByNameIPv4AsyncResponse_t *pMsgArgs = (_GetHostByNameIPv4AsyncResponse_t *)_SL_RESP_ARGS_START(pVoidBuf);
IanBenzMaxim 0:33d4e66780c0 953
IanBenzMaxim 0:33d4e66780c0 954 SL_DRV_PROTECTION_OBJ_LOCK_FOREVER();
IanBenzMaxim 0:33d4e66780c0 955
IanBenzMaxim 0:33d4e66780c0 956 VERIFY_SOCKET_CB(NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs);
IanBenzMaxim 0:33d4e66780c0 957
IanBenzMaxim 0:33d4e66780c0 958 /*IPv6 */
IanBenzMaxim 0:33d4e66780c0 959 if(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].AdditionalData & SL_NETAPP_FAMILY_MASK)
IanBenzMaxim 0:33d4e66780c0 960 {
IanBenzMaxim 0:33d4e66780c0 961 sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_GetHostByNameIPv6AsyncResponse_t));
IanBenzMaxim 0:33d4e66780c0 962 }
IanBenzMaxim 0:33d4e66780c0 963 /*IPv4 */
IanBenzMaxim 0:33d4e66780c0 964 else
IanBenzMaxim 0:33d4e66780c0 965 {
IanBenzMaxim 0:33d4e66780c0 966 sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_GetHostByNameIPv4AsyncResponse_t));
IanBenzMaxim 0:33d4e66780c0 967 }
IanBenzMaxim 0:33d4e66780c0 968
IanBenzMaxim 0:33d4e66780c0 969 SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj);
IanBenzMaxim 0:33d4e66780c0 970 SL_DRV_PROTECTION_OBJ_UNLOCK();
IanBenzMaxim 0:33d4e66780c0 971
IanBenzMaxim 0:33d4e66780c0 972 return SL_RET_CODE_OK;
IanBenzMaxim 0:33d4e66780c0 973 }
IanBenzMaxim 0:33d4e66780c0 974
IanBenzMaxim 0:33d4e66780c0 975
IanBenzMaxim 0:33d4e66780c0 976 #ifndef SL_TINY_EXT
IanBenzMaxim 0:33d4e66780c0 977 static void CopyPingResultsToReport(_PingReportResponse_t *pResults,SlPingReport_t *pReport)
IanBenzMaxim 0:33d4e66780c0 978 {
IanBenzMaxim 0:33d4e66780c0 979 pReport->PacketsSent = pResults->numSendsPings;
IanBenzMaxim 0:33d4e66780c0 980 pReport->PacketsReceived = pResults->numSuccsessPings;
IanBenzMaxim 0:33d4e66780c0 981 pReport->MinRoundTime = pResults->rttMin;
IanBenzMaxim 0:33d4e66780c0 982 pReport->MaxRoundTime = pResults->rttMax;
IanBenzMaxim 0:33d4e66780c0 983 pReport->AvgRoundTime = pResults->rttAvg;
IanBenzMaxim 0:33d4e66780c0 984 pReport->TestTime = pResults->testTime;
IanBenzMaxim 0:33d4e66780c0 985 }
IanBenzMaxim 0:33d4e66780c0 986
IanBenzMaxim 0:33d4e66780c0 987 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 988 /* _sl_HandleAsync_PingResponse */
IanBenzMaxim 0:33d4e66780c0 989 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 990 _SlReturnVal_t _sl_HandleAsync_PingResponse(void *pVoidBuf)
IanBenzMaxim 0:33d4e66780c0 991 {
IanBenzMaxim 0:33d4e66780c0 992 _PingReportResponse_t *pMsgArgs = (_PingReportResponse_t *)_SL_RESP_ARGS_START(pVoidBuf);
IanBenzMaxim 0:33d4e66780c0 993 SlPingReport_t pingReport;
IanBenzMaxim 0:33d4e66780c0 994
IanBenzMaxim 0:33d4e66780c0 995 if(pPingCallBackFunc)
IanBenzMaxim 0:33d4e66780c0 996 {
IanBenzMaxim 0:33d4e66780c0 997 CopyPingResultsToReport(pMsgArgs,&pingReport);
IanBenzMaxim 0:33d4e66780c0 998 pPingCallBackFunc(&pingReport);
IanBenzMaxim 0:33d4e66780c0 999 }
IanBenzMaxim 0:33d4e66780c0 1000 else
IanBenzMaxim 0:33d4e66780c0 1001 {
IanBenzMaxim 0:33d4e66780c0 1002
IanBenzMaxim 0:33d4e66780c0 1003 SL_DRV_PROTECTION_OBJ_LOCK_FOREVER();
IanBenzMaxim 0:33d4e66780c0 1004
IanBenzMaxim 0:33d4e66780c0 1005 VERIFY_SOCKET_CB(NULL != g_pCB->PingCB.PingAsync.pAsyncRsp);
IanBenzMaxim 0:33d4e66780c0 1006
IanBenzMaxim 0:33d4e66780c0 1007 if (NULL != g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs)
IanBenzMaxim 0:33d4e66780c0 1008 {
IanBenzMaxim 0:33d4e66780c0 1009 sl_Memcpy(g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].pRespArgs, pMsgArgs, sizeof(_PingReportResponse_t));
IanBenzMaxim 0:33d4e66780c0 1010 SL_DRV_SYNC_OBJ_SIGNAL(&g_pCB->ObjPool[g_pCB->FunctionParams.AsyncExt.ActionIndex].SyncObj);
IanBenzMaxim 0:33d4e66780c0 1011 }
IanBenzMaxim 0:33d4e66780c0 1012 SL_DRV_PROTECTION_OBJ_UNLOCK();
IanBenzMaxim 0:33d4e66780c0 1013 }
IanBenzMaxim 0:33d4e66780c0 1014
IanBenzMaxim 0:33d4e66780c0 1015 return SL_RET_CODE_OK;
IanBenzMaxim 0:33d4e66780c0 1016 }
IanBenzMaxim 0:33d4e66780c0 1017 #endif
IanBenzMaxim 0:33d4e66780c0 1018
IanBenzMaxim 0:33d4e66780c0 1019 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 1020 /* sl_PingStart */
IanBenzMaxim 0:33d4e66780c0 1021 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 1022 typedef union
IanBenzMaxim 0:33d4e66780c0 1023 {
IanBenzMaxim 0:33d4e66780c0 1024 _PingStartCommand_t Cmd;
IanBenzMaxim 0:33d4e66780c0 1025 _PingReportResponse_t Rsp;
IanBenzMaxim 0:33d4e66780c0 1026 }_SlPingStartMsg_u;
IanBenzMaxim 0:33d4e66780c0 1027
IanBenzMaxim 0:33d4e66780c0 1028
IanBenzMaxim 0:33d4e66780c0 1029 typedef enum
IanBenzMaxim 0:33d4e66780c0 1030 {
IanBenzMaxim 0:33d4e66780c0 1031 CMD_PING_TEST_RUNNING = 0,
IanBenzMaxim 0:33d4e66780c0 1032 CMD_PING_TEST_STOPPED
IanBenzMaxim 0:33d4e66780c0 1033 }_SlPingStatus_e;
IanBenzMaxim 0:33d4e66780c0 1034
IanBenzMaxim 0:33d4e66780c0 1035
IanBenzMaxim 0:33d4e66780c0 1036 #if _SL_INCLUDE_FUNC(sl_NetAppPingStart)
IanBenzMaxim 0:33d4e66780c0 1037 _i16 sl_NetAppPingStart(const SlPingStartCommand_t* pPingParams,const _u8 family,SlPingReport_t *pReport,const P_SL_DEV_PING_CALLBACK pPingCallback)
IanBenzMaxim 0:33d4e66780c0 1038 {
IanBenzMaxim 0:33d4e66780c0 1039 _SlCmdCtrl_t CmdCtrl = {0, (_SlArgSize_t)sizeof(_PingStartCommand_t), (_SlArgSize_t)sizeof(_BasicResponse_t)};
IanBenzMaxim 0:33d4e66780c0 1040 _SlPingStartMsg_u Msg;
IanBenzMaxim 0:33d4e66780c0 1041 _PingReportResponse_t PingRsp;
IanBenzMaxim 0:33d4e66780c0 1042 _u8 ObjIdx = MAX_CONCURRENT_ACTIONS;
IanBenzMaxim 0:33d4e66780c0 1043
IanBenzMaxim 0:33d4e66780c0 1044 /* verify no erorr handling in progress. if in progress than
IanBenzMaxim 0:33d4e66780c0 1045 ignore the API execution and return immediately with an error */
IanBenzMaxim 0:33d4e66780c0 1046 VERIFY_NO_ERROR_HANDLING_IN_PROGRESS();
IanBenzMaxim 0:33d4e66780c0 1047
IanBenzMaxim 0:33d4e66780c0 1048 if( 0 == pPingParams->Ip )
IanBenzMaxim 0:33d4e66780c0 1049 {/* stop any ongoing ping */
IanBenzMaxim 0:33d4e66780c0 1050 return _SlDrvBasicCmd(SL_OPCODE_NETAPP_PINGSTOP);
IanBenzMaxim 0:33d4e66780c0 1051 }
IanBenzMaxim 0:33d4e66780c0 1052
IanBenzMaxim 0:33d4e66780c0 1053 if(SL_AF_INET == family)
IanBenzMaxim 0:33d4e66780c0 1054 {
IanBenzMaxim 0:33d4e66780c0 1055 CmdCtrl.Opcode = SL_OPCODE_NETAPP_PINGSTART;
IanBenzMaxim 0:33d4e66780c0 1056 sl_Memcpy(&Msg.Cmd.ip0, &pPingParams->Ip, SL_IPV4_ADDRESS_SIZE);
IanBenzMaxim 0:33d4e66780c0 1057 }
IanBenzMaxim 0:33d4e66780c0 1058 else
IanBenzMaxim 0:33d4e66780c0 1059 {
IanBenzMaxim 0:33d4e66780c0 1060 CmdCtrl.Opcode = SL_OPCODE_NETAPP_PINGSTART_V6;
IanBenzMaxim 0:33d4e66780c0 1061 sl_Memcpy(&Msg.Cmd.ip0, &pPingParams->Ip, SL_IPV6_ADDRESS_SIZE);
IanBenzMaxim 0:33d4e66780c0 1062 }
IanBenzMaxim 0:33d4e66780c0 1063
IanBenzMaxim 0:33d4e66780c0 1064 Msg.Cmd.pingIntervalTime = pPingParams->PingIntervalTime;
IanBenzMaxim 0:33d4e66780c0 1065 Msg.Cmd.PingSize = pPingParams->PingSize;
IanBenzMaxim 0:33d4e66780c0 1066 Msg.Cmd.pingRequestTimeout = pPingParams->PingRequestTimeout;
IanBenzMaxim 0:33d4e66780c0 1067 Msg.Cmd.totalNumberOfAttempts = pPingParams->TotalNumberOfAttempts;
IanBenzMaxim 0:33d4e66780c0 1068 Msg.Cmd.flags = pPingParams->Flags;
IanBenzMaxim 0:33d4e66780c0 1069
IanBenzMaxim 0:33d4e66780c0 1070
IanBenzMaxim 0:33d4e66780c0 1071 if( pPingCallback )
IanBenzMaxim 0:33d4e66780c0 1072 {
IanBenzMaxim 0:33d4e66780c0 1073 pPingCallBackFunc = pPingCallback;
IanBenzMaxim 0:33d4e66780c0 1074 }
IanBenzMaxim 0:33d4e66780c0 1075 else
IanBenzMaxim 0:33d4e66780c0 1076 {
IanBenzMaxim 0:33d4e66780c0 1077 /*Use Obj to issue the command, if not available try later */
IanBenzMaxim 0:33d4e66780c0 1078 ObjIdx = (_u8)_SlDrvWaitForPoolObj(PING_ID,SL_MAX_SOCKETS);
IanBenzMaxim 0:33d4e66780c0 1079 if (MAX_CONCURRENT_ACTIONS == ObjIdx)
IanBenzMaxim 0:33d4e66780c0 1080 {
IanBenzMaxim 0:33d4e66780c0 1081 return SL_POOL_IS_EMPTY;
IanBenzMaxim 0:33d4e66780c0 1082 }
IanBenzMaxim 0:33d4e66780c0 1083 OSI_RET_OK_CHECK(sl_LockObjLock(&g_pCB->ProtectionLockObj, SL_OS_WAIT_FOREVER));
IanBenzMaxim 0:33d4e66780c0 1084 /* async response handler for non callback mode */
IanBenzMaxim 0:33d4e66780c0 1085 g_pCB->ObjPool[ObjIdx].pRespArgs = (_u8 *)&PingRsp;
IanBenzMaxim 0:33d4e66780c0 1086 pPingCallBackFunc = NULL;
IanBenzMaxim 0:33d4e66780c0 1087 OSI_RET_OK_CHECK(sl_LockObjUnlock(&g_pCB->ProtectionLockObj));
IanBenzMaxim 0:33d4e66780c0 1088 }
IanBenzMaxim 0:33d4e66780c0 1089
IanBenzMaxim 0:33d4e66780c0 1090
IanBenzMaxim 0:33d4e66780c0 1091 VERIFY_RET_OK(_SlDrvCmdOp(&CmdCtrl, &Msg, NULL));
IanBenzMaxim 0:33d4e66780c0 1092 /*send the command*/
IanBenzMaxim 0:33d4e66780c0 1093 if(CMD_PING_TEST_RUNNING == (_i16)Msg.Rsp.status || CMD_PING_TEST_STOPPED == (_i16)Msg.Rsp.status )
IanBenzMaxim 0:33d4e66780c0 1094 {
IanBenzMaxim 0:33d4e66780c0 1095 /* block waiting for results if no callback function is used */
IanBenzMaxim 0:33d4e66780c0 1096 if( NULL == pPingCallback )
IanBenzMaxim 0:33d4e66780c0 1097 {
IanBenzMaxim 0:33d4e66780c0 1098 #ifdef SL_TINY_EXT
IanBenzMaxim 0:33d4e66780c0 1099 _SlDrvSyncObjWaitForever(&g_pCB->ObjPool[ObjIdx].SyncObj);
IanBenzMaxim 0:33d4e66780c0 1100 #else
IanBenzMaxim 0:33d4e66780c0 1101 SL_DRV_SYNC_OBJ_WAIT_TIMEOUT(&g_pCB->ObjPool[ObjIdx].SyncObj,
IanBenzMaxim 0:33d4e66780c0 1102 SL_DRIVER_TIMEOUT_LONG,
IanBenzMaxim 0:33d4e66780c0 1103 SL_DRIVER_API_NETAPP_PING_START
IanBenzMaxim 0:33d4e66780c0 1104 );
IanBenzMaxim 0:33d4e66780c0 1105 #endif
IanBenzMaxim 0:33d4e66780c0 1106
IanBenzMaxim 0:33d4e66780c0 1107 if( SL_OS_RET_CODE_OK == (_i16)PingRsp.status )
IanBenzMaxim 0:33d4e66780c0 1108 {
IanBenzMaxim 0:33d4e66780c0 1109 CopyPingResultsToReport(&PingRsp,pReport);
IanBenzMaxim 0:33d4e66780c0 1110 }
IanBenzMaxim 0:33d4e66780c0 1111 _SlDrvReleasePoolObj(ObjIdx);
IanBenzMaxim 0:33d4e66780c0 1112 }
IanBenzMaxim 0:33d4e66780c0 1113 }
IanBenzMaxim 0:33d4e66780c0 1114 else
IanBenzMaxim 0:33d4e66780c0 1115 { /* ping failure, no async response */
IanBenzMaxim 0:33d4e66780c0 1116 if( NULL == pPingCallback )
IanBenzMaxim 0:33d4e66780c0 1117 {
IanBenzMaxim 0:33d4e66780c0 1118 _SlDrvReleasePoolObj(ObjIdx);
IanBenzMaxim 0:33d4e66780c0 1119 }
IanBenzMaxim 0:33d4e66780c0 1120 }
IanBenzMaxim 0:33d4e66780c0 1121
IanBenzMaxim 0:33d4e66780c0 1122 return (_i16)Msg.Rsp.status;
IanBenzMaxim 0:33d4e66780c0 1123 }
IanBenzMaxim 0:33d4e66780c0 1124 #endif
IanBenzMaxim 0:33d4e66780c0 1125
IanBenzMaxim 0:33d4e66780c0 1126 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 1127 /* sl_NetAppSet */
IanBenzMaxim 0:33d4e66780c0 1128 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 1129 typedef union
IanBenzMaxim 0:33d4e66780c0 1130 {
IanBenzMaxim 0:33d4e66780c0 1131 _NetAppSetGet_t Cmd;
IanBenzMaxim 0:33d4e66780c0 1132 _BasicResponse_t Rsp;
IanBenzMaxim 0:33d4e66780c0 1133 }_SlNetAppMsgSet_u;
IanBenzMaxim 0:33d4e66780c0 1134
IanBenzMaxim 0:33d4e66780c0 1135
IanBenzMaxim 0:33d4e66780c0 1136 #if _SL_INCLUDE_FUNC(sl_NetAppSet)
IanBenzMaxim 0:33d4e66780c0 1137
IanBenzMaxim 0:33d4e66780c0 1138 static const _SlCmdCtrl_t _SlNetAppSetCmdCtrl =
IanBenzMaxim 0:33d4e66780c0 1139 {
IanBenzMaxim 0:33d4e66780c0 1140 SL_OPCODE_NETAPP_NETAPPSET,
IanBenzMaxim 0:33d4e66780c0 1141 (_SlArgSize_t)sizeof(_NetAppSetGet_t),
IanBenzMaxim 0:33d4e66780c0 1142 (_SlArgSize_t)sizeof(_BasicResponse_t)
IanBenzMaxim 0:33d4e66780c0 1143 };
IanBenzMaxim 0:33d4e66780c0 1144
IanBenzMaxim 0:33d4e66780c0 1145 _i32 sl_NetAppSet(const _u8 AppId ,const _u8 Option,const _u8 OptionLen,const _u8 *pOptionValue)
IanBenzMaxim 0:33d4e66780c0 1146 {
IanBenzMaxim 0:33d4e66780c0 1147 _SlNetAppMsgSet_u Msg;
IanBenzMaxim 0:33d4e66780c0 1148 _SlCmdExt_t CmdExt;
IanBenzMaxim 0:33d4e66780c0 1149
IanBenzMaxim 0:33d4e66780c0 1150 /* verify no erorr handling in progress. if in progress than
IanBenzMaxim 0:33d4e66780c0 1151 ignore the API execution and return immediately with an error */
IanBenzMaxim 0:33d4e66780c0 1152 VERIFY_NO_ERROR_HANDLING_IN_PROGRESS();
IanBenzMaxim 0:33d4e66780c0 1153
IanBenzMaxim 0:33d4e66780c0 1154 _SlDrvResetCmdExt(&CmdExt);
IanBenzMaxim 0:33d4e66780c0 1155 CmdExt.TxPayloadLen = (OptionLen+3) & (~3);
IanBenzMaxim 0:33d4e66780c0 1156 CmdExt.pTxPayload = (_u8 *)pOptionValue;
IanBenzMaxim 0:33d4e66780c0 1157
IanBenzMaxim 0:33d4e66780c0 1158
IanBenzMaxim 0:33d4e66780c0 1159 Msg.Cmd.AppId = AppId;
IanBenzMaxim 0:33d4e66780c0 1160 Msg.Cmd.ConfigLen = OptionLen;
IanBenzMaxim 0:33d4e66780c0 1161 Msg.Cmd.ConfigOpt = Option;
IanBenzMaxim 0:33d4e66780c0 1162
IanBenzMaxim 0:33d4e66780c0 1163 VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppSetCmdCtrl, &Msg, &CmdExt));
IanBenzMaxim 0:33d4e66780c0 1164
IanBenzMaxim 0:33d4e66780c0 1165 return (_i16)Msg.Rsp.status;
IanBenzMaxim 0:33d4e66780c0 1166 }
IanBenzMaxim 0:33d4e66780c0 1167 #endif
IanBenzMaxim 0:33d4e66780c0 1168
IanBenzMaxim 0:33d4e66780c0 1169 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 1170 /* sl_NetAppSendTokenValue */
IanBenzMaxim 0:33d4e66780c0 1171 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 1172 typedef union
IanBenzMaxim 0:33d4e66780c0 1173 {
IanBenzMaxim 0:33d4e66780c0 1174 sl_NetAppHttpServerSendToken_t Cmd;
IanBenzMaxim 0:33d4e66780c0 1175 _BasicResponse_t Rsp;
IanBenzMaxim 0:33d4e66780c0 1176 }_SlNetAppMsgSendTokenValue_u;
IanBenzMaxim 0:33d4e66780c0 1177
IanBenzMaxim 0:33d4e66780c0 1178
IanBenzMaxim 0:33d4e66780c0 1179
IanBenzMaxim 0:33d4e66780c0 1180 #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
IanBenzMaxim 0:33d4e66780c0 1181 const _SlCmdCtrl_t _SlNetAppSendTokenValueCmdCtrl =
IanBenzMaxim 0:33d4e66780c0 1182 {
IanBenzMaxim 0:33d4e66780c0 1183 SL_OPCODE_NETAPP_HTTPSENDTOKENVALUE,
IanBenzMaxim 0:33d4e66780c0 1184 (_SlArgSize_t)sizeof(sl_NetAppHttpServerSendToken_t),
IanBenzMaxim 0:33d4e66780c0 1185 (_SlArgSize_t)sizeof(_BasicResponse_t)
IanBenzMaxim 0:33d4e66780c0 1186 };
IanBenzMaxim 0:33d4e66780c0 1187
IanBenzMaxim 0:33d4e66780c0 1188 _u16 _sl_NetAppSendTokenValue(slHttpServerData_t * Token_value)
IanBenzMaxim 0:33d4e66780c0 1189 {
IanBenzMaxim 0:33d4e66780c0 1190 _SlNetAppMsgSendTokenValue_u Msg;
IanBenzMaxim 0:33d4e66780c0 1191 _SlCmdExt_t CmdExt;
IanBenzMaxim 0:33d4e66780c0 1192
IanBenzMaxim 0:33d4e66780c0 1193 CmdExt.TxPayloadLen = (Token_value->value_len+3) & (~3);
IanBenzMaxim 0:33d4e66780c0 1194 CmdExt.RxPayloadLen = 0;
IanBenzMaxim 0:33d4e66780c0 1195 CmdExt.pTxPayload = (_u8 *) Token_value->token_value;
IanBenzMaxim 0:33d4e66780c0 1196 CmdExt.pRxPayload = NULL;
IanBenzMaxim 0:33d4e66780c0 1197
IanBenzMaxim 0:33d4e66780c0 1198 Msg.Cmd.token_value_len = Token_value->value_len;
IanBenzMaxim 0:33d4e66780c0 1199 Msg.Cmd.token_name_len = Token_value->name_len;
IanBenzMaxim 0:33d4e66780c0 1200 sl_Memcpy(&Msg.Cmd.token_name[0], Token_value->token_name, Token_value->name_len);
IanBenzMaxim 0:33d4e66780c0 1201
IanBenzMaxim 0:33d4e66780c0 1202
IanBenzMaxim 0:33d4e66780c0 1203 VERIFY_RET_OK(_SlDrvCmdSend((_SlCmdCtrl_t *)&_SlNetAppSendTokenValueCmdCtrl, &Msg, &CmdExt));
IanBenzMaxim 0:33d4e66780c0 1204
IanBenzMaxim 0:33d4e66780c0 1205 return Msg.Rsp.status;
IanBenzMaxim 0:33d4e66780c0 1206 }
IanBenzMaxim 0:33d4e66780c0 1207 #endif
IanBenzMaxim 0:33d4e66780c0 1208
IanBenzMaxim 0:33d4e66780c0 1209
IanBenzMaxim 0:33d4e66780c0 1210 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 1211 /* sl_NetAppGet */
IanBenzMaxim 0:33d4e66780c0 1212 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 1213 typedef union
IanBenzMaxim 0:33d4e66780c0 1214 {
IanBenzMaxim 0:33d4e66780c0 1215 _NetAppSetGet_t Cmd;
IanBenzMaxim 0:33d4e66780c0 1216 _NetAppSetGet_t Rsp;
IanBenzMaxim 0:33d4e66780c0 1217 }_SlNetAppMsgGet_u;
IanBenzMaxim 0:33d4e66780c0 1218
IanBenzMaxim 0:33d4e66780c0 1219
IanBenzMaxim 0:33d4e66780c0 1220 #if _SL_INCLUDE_FUNC(sl_NetAppGet)
IanBenzMaxim 0:33d4e66780c0 1221 static const _SlCmdCtrl_t _SlNetAppGetCmdCtrl =
IanBenzMaxim 0:33d4e66780c0 1222 {
IanBenzMaxim 0:33d4e66780c0 1223 SL_OPCODE_NETAPP_NETAPPGET,
IanBenzMaxim 0:33d4e66780c0 1224 (_SlArgSize_t)sizeof(_NetAppSetGet_t),
IanBenzMaxim 0:33d4e66780c0 1225 (_SlArgSize_t)sizeof(_NetAppSetGet_t)
IanBenzMaxim 0:33d4e66780c0 1226 };
IanBenzMaxim 0:33d4e66780c0 1227
IanBenzMaxim 0:33d4e66780c0 1228 _i32 sl_NetAppGet(const _u8 AppId,const _u8 Option,_u8 *pOptionLen, _u8 *pOptionValue)
IanBenzMaxim 0:33d4e66780c0 1229 {
IanBenzMaxim 0:33d4e66780c0 1230 _SlNetAppMsgGet_u Msg;
IanBenzMaxim 0:33d4e66780c0 1231 _SlCmdExt_t CmdExt;
IanBenzMaxim 0:33d4e66780c0 1232
IanBenzMaxim 0:33d4e66780c0 1233 /* verify no erorr handling in progress. if in progress than
IanBenzMaxim 0:33d4e66780c0 1234 ignore the API execution and return immediately with an error */
IanBenzMaxim 0:33d4e66780c0 1235 VERIFY_NO_ERROR_HANDLING_IN_PROGRESS();
IanBenzMaxim 0:33d4e66780c0 1236
IanBenzMaxim 0:33d4e66780c0 1237 if (*pOptionLen == 0)
IanBenzMaxim 0:33d4e66780c0 1238 {
IanBenzMaxim 0:33d4e66780c0 1239 return SL_EZEROLEN;
IanBenzMaxim 0:33d4e66780c0 1240 }
IanBenzMaxim 0:33d4e66780c0 1241
IanBenzMaxim 0:33d4e66780c0 1242 _SlDrvResetCmdExt(&CmdExt);
IanBenzMaxim 0:33d4e66780c0 1243 CmdExt.RxPayloadLen = (_i16)(*pOptionLen);
IanBenzMaxim 0:33d4e66780c0 1244 CmdExt.pRxPayload = (_u8 *)pOptionValue;
IanBenzMaxim 0:33d4e66780c0 1245
IanBenzMaxim 0:33d4e66780c0 1246 Msg.Cmd.AppId = AppId;
IanBenzMaxim 0:33d4e66780c0 1247 Msg.Cmd.ConfigOpt = Option;
IanBenzMaxim 0:33d4e66780c0 1248 VERIFY_RET_OK(_SlDrvCmdOp((_SlCmdCtrl_t *)&_SlNetAppGetCmdCtrl, &Msg, &CmdExt));
IanBenzMaxim 0:33d4e66780c0 1249
IanBenzMaxim 0:33d4e66780c0 1250
IanBenzMaxim 0:33d4e66780c0 1251 if (CmdExt.RxPayloadLen < CmdExt.ActualRxPayloadLen)
IanBenzMaxim 0:33d4e66780c0 1252 {
IanBenzMaxim 0:33d4e66780c0 1253 *pOptionLen = (_u8)CmdExt.RxPayloadLen;
IanBenzMaxim 0:33d4e66780c0 1254 return SL_ESMALLBUF;
IanBenzMaxim 0:33d4e66780c0 1255 }
IanBenzMaxim 0:33d4e66780c0 1256 else
IanBenzMaxim 0:33d4e66780c0 1257 {
IanBenzMaxim 0:33d4e66780c0 1258 *pOptionLen = (_u8)CmdExt.ActualRxPayloadLen;
IanBenzMaxim 0:33d4e66780c0 1259 }
IanBenzMaxim 0:33d4e66780c0 1260
IanBenzMaxim 0:33d4e66780c0 1261 return (_i16)Msg.Rsp.Status;
IanBenzMaxim 0:33d4e66780c0 1262 }
IanBenzMaxim 0:33d4e66780c0 1263 #endif
IanBenzMaxim 0:33d4e66780c0 1264
IanBenzMaxim 0:33d4e66780c0 1265
IanBenzMaxim 0:33d4e66780c0 1266 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 1267 /* _SlDrvNetAppEventHandler */
IanBenzMaxim 0:33d4e66780c0 1268 /*****************************************************************************/
IanBenzMaxim 0:33d4e66780c0 1269 _SlReturnVal_t _SlDrvNetAppEventHandler(void* pArgs)
IanBenzMaxim 0:33d4e66780c0 1270 {
IanBenzMaxim 0:33d4e66780c0 1271 _SlResponseHeader_t *pHdr = (_SlResponseHeader_t *)pArgs;
IanBenzMaxim 0:33d4e66780c0 1272 #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
IanBenzMaxim 0:33d4e66780c0 1273 SlHttpServerEvent_t httpServerEvent;
IanBenzMaxim 0:33d4e66780c0 1274 SlHttpServerResponse_t httpServerResponse;
IanBenzMaxim 0:33d4e66780c0 1275 #endif
IanBenzMaxim 0:33d4e66780c0 1276
IanBenzMaxim 0:33d4e66780c0 1277 switch(pHdr->GenHeader.Opcode)
IanBenzMaxim 0:33d4e66780c0 1278 {
IanBenzMaxim 0:33d4e66780c0 1279 case SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE:
IanBenzMaxim 0:33d4e66780c0 1280 case SL_OPCODE_NETAPP_DNSGETHOSTBYNAMEASYNCRESPONSE_V6:
IanBenzMaxim 0:33d4e66780c0 1281 _sl_HandleAsync_DnsGetHostByName(pArgs);
IanBenzMaxim 0:33d4e66780c0 1282 break;
IanBenzMaxim 0:33d4e66780c0 1283 #ifndef SL_TINY_EXT
IanBenzMaxim 0:33d4e66780c0 1284 case SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE:
IanBenzMaxim 0:33d4e66780c0 1285 case SL_OPCODE_NETAPP_MDNSGETHOSTBYSERVICEASYNCRESPONSE_V6:
IanBenzMaxim 0:33d4e66780c0 1286 _sl_HandleAsync_DnsGetHostByService(pArgs);
IanBenzMaxim 0:33d4e66780c0 1287 break;
IanBenzMaxim 0:33d4e66780c0 1288 case SL_OPCODE_NETAPP_PINGREPORTREQUESTRESPONSE:
IanBenzMaxim 0:33d4e66780c0 1289 _sl_HandleAsync_PingResponse(pArgs);
IanBenzMaxim 0:33d4e66780c0 1290 break;
IanBenzMaxim 0:33d4e66780c0 1291 #endif
IanBenzMaxim 0:33d4e66780c0 1292
IanBenzMaxim 0:33d4e66780c0 1293 #if defined(sl_HttpServerCallback) || defined(EXT_LIB_REGISTERED_HTTP_SERVER_EVENTS)
IanBenzMaxim 0:33d4e66780c0 1294 case SL_OPCODE_NETAPP_HTTPGETTOKENVALUE:
IanBenzMaxim 0:33d4e66780c0 1295 {
IanBenzMaxim 0:33d4e66780c0 1296 _u8 *pTokenName;
IanBenzMaxim 0:33d4e66780c0 1297 slHttpServerData_t Token_value;
IanBenzMaxim 0:33d4e66780c0 1298 sl_NetAppHttpServerGetToken_t *httpGetToken = (sl_NetAppHttpServerGetToken_t *)_SL_RESP_ARGS_START(pHdr);
IanBenzMaxim 0:33d4e66780c0 1299 pTokenName = (_u8 *)((sl_NetAppHttpServerGetToken_t *)httpGetToken + 1);
IanBenzMaxim 0:33d4e66780c0 1300
IanBenzMaxim 0:33d4e66780c0 1301 httpServerResponse.Response = SL_NETAPP_HTTPSETTOKENVALUE;
IanBenzMaxim 0:33d4e66780c0 1302 httpServerResponse.ResponseData.token_value.len = MAX_TOKEN_VALUE_LEN;
IanBenzMaxim 0:33d4e66780c0 1303
IanBenzMaxim 0:33d4e66780c0 1304 /* Reuse the async buffer for getting the token value response from the user */
IanBenzMaxim 0:33d4e66780c0 1305 httpServerResponse.ResponseData.token_value.data = (_u8 *)_SL_RESP_ARGS_START(pHdr) + MAX_TOKEN_NAME_LEN;
IanBenzMaxim 0:33d4e66780c0 1306
IanBenzMaxim 0:33d4e66780c0 1307 httpServerEvent.Event = SL_NETAPP_HTTPGETTOKENVALUE_EVENT;
IanBenzMaxim 0:33d4e66780c0 1308 httpServerEvent.EventData.httpTokenName.len = httpGetToken->token_name_len;
IanBenzMaxim 0:33d4e66780c0 1309 httpServerEvent.EventData.httpTokenName.data = pTokenName;
IanBenzMaxim 0:33d4e66780c0 1310
IanBenzMaxim 0:33d4e66780c0 1311 Token_value.token_name = pTokenName;
IanBenzMaxim 0:33d4e66780c0 1312
IanBenzMaxim 0:33d4e66780c0 1313 _SlDrvDispatchHttpServerEvents (&httpServerEvent, &httpServerResponse);
IanBenzMaxim 0:33d4e66780c0 1314
IanBenzMaxim 0:33d4e66780c0 1315 Token_value.value_len = httpServerResponse.ResponseData.token_value.len;
IanBenzMaxim 0:33d4e66780c0 1316 Token_value.name_len = httpServerEvent.EventData.httpTokenName.len;
IanBenzMaxim 0:33d4e66780c0 1317 Token_value.token_value = httpServerResponse.ResponseData.token_value.data;
IanBenzMaxim 0:33d4e66780c0 1318
IanBenzMaxim 0:33d4e66780c0 1319
IanBenzMaxim 0:33d4e66780c0 1320 _sl_NetAppSendTokenValue(&Token_value);
IanBenzMaxim 0:33d4e66780c0 1321 }
IanBenzMaxim 0:33d4e66780c0 1322 break;
IanBenzMaxim 0:33d4e66780c0 1323
IanBenzMaxim 0:33d4e66780c0 1324 case SL_OPCODE_NETAPP_HTTPPOSTTOKENVALUE:
IanBenzMaxim 0:33d4e66780c0 1325 {
IanBenzMaxim 0:33d4e66780c0 1326 _u8 *pPostParams;
IanBenzMaxim 0:33d4e66780c0 1327
IanBenzMaxim 0:33d4e66780c0 1328 sl_NetAppHttpServerPostToken_t *httpPostTokenArgs = (sl_NetAppHttpServerPostToken_t *)_SL_RESP_ARGS_START(pHdr);
IanBenzMaxim 0:33d4e66780c0 1329 pPostParams = (_u8 *)((sl_NetAppHttpServerPostToken_t *)httpPostTokenArgs + 1);
IanBenzMaxim 0:33d4e66780c0 1330
IanBenzMaxim 0:33d4e66780c0 1331 httpServerEvent.Event = SL_NETAPP_HTTPPOSTTOKENVALUE_EVENT;
IanBenzMaxim 0:33d4e66780c0 1332
IanBenzMaxim 0:33d4e66780c0 1333 httpServerEvent.EventData.httpPostData.action.len = httpPostTokenArgs->post_action_len;
IanBenzMaxim 0:33d4e66780c0 1334 httpServerEvent.EventData.httpPostData.action.data = pPostParams;
IanBenzMaxim 0:33d4e66780c0 1335 pPostParams+=httpPostTokenArgs->post_action_len;
IanBenzMaxim 0:33d4e66780c0 1336
IanBenzMaxim 0:33d4e66780c0 1337 httpServerEvent.EventData.httpPostData.token_name.len = httpPostTokenArgs->token_name_len;
IanBenzMaxim 0:33d4e66780c0 1338 httpServerEvent.EventData.httpPostData.token_name.data = pPostParams;
IanBenzMaxim 0:33d4e66780c0 1339 pPostParams+=httpPostTokenArgs->token_name_len;
IanBenzMaxim 0:33d4e66780c0 1340
IanBenzMaxim 0:33d4e66780c0 1341 httpServerEvent.EventData.httpPostData.token_value.len = httpPostTokenArgs->token_value_len;
IanBenzMaxim 0:33d4e66780c0 1342 httpServerEvent.EventData.httpPostData.token_value.data = pPostParams;
IanBenzMaxim 0:33d4e66780c0 1343
IanBenzMaxim 0:33d4e66780c0 1344 httpServerResponse.Response = SL_NETAPP_RESPONSE_NONE;
IanBenzMaxim 0:33d4e66780c0 1345
IanBenzMaxim 0:33d4e66780c0 1346 _SlDrvDispatchHttpServerEvents (&httpServerEvent, &httpServerResponse);
IanBenzMaxim 0:33d4e66780c0 1347
IanBenzMaxim 0:33d4e66780c0 1348 }
IanBenzMaxim 0:33d4e66780c0 1349 break;
IanBenzMaxim 0:33d4e66780c0 1350 #endif
IanBenzMaxim 0:33d4e66780c0 1351
IanBenzMaxim 0:33d4e66780c0 1352
IanBenzMaxim 0:33d4e66780c0 1353 default:
IanBenzMaxim 0:33d4e66780c0 1354 SL_ERROR_TRACE2(MSG_305, "ASSERT: _SlDrvNetAppEventHandler : invalid opcode = 0x%x = %1", pHdr->GenHeader.Opcode, pHdr->GenHeader.Opcode);
IanBenzMaxim 0:33d4e66780c0 1355 VERIFY_PROTOCOL(0);
IanBenzMaxim 0:33d4e66780c0 1356 }
IanBenzMaxim 0:33d4e66780c0 1357
IanBenzMaxim 0:33d4e66780c0 1358 return SL_RET_CODE_OK;
IanBenzMaxim 0:33d4e66780c0 1359 }
IanBenzMaxim 0:33d4e66780c0 1360